(a) Given three positive numbers x, y and z, we can determine if these are the lengths of a triangle by checking that the following inequalities hold simultaneously: z < x +y x < y + z y < z + x. Write a function which implements the above idea. Its exact declaration should be: bool is_triangle (double x, double y, double z) The function should contain no cout statements. Here are some test cases: is triangle (0,0,0) → false • is triangle(-1,1,1) → false • is triangle(1,1,10) → false • is triangle(1,10,1) → false • is triangle (1,1,1) → true • is-triangle(2,13,12) H true (b) Write a function which computes the area of a triangle given three side lengths via Heron's formula: https://en.wikipedia.org/wiki/Heron%27s_formula Assume that the side lengths form a valid triangle. Its exact declaration should be: double area(double x, double y, double z) The function should contain no cout statements. Here are some test cases: • area(1,1,1) H 0.433013 • area(2,13,12) H 10.7906 • area(12,13,2) → 10.7906 (c) Write a main function which reads three double values from the standard input. If the values are the side lengths of a triangle, the program should print: The values 3.0, 4.0 and 5.0 are the side lengths of a triangle with area 6.0. Otherwise: The values 1.1, 2.0 and 5.0 are not the side lengths of a triangle. All floating point values should be printed with 6 digits of precision. For full credit, the main function must call the functions from (a) and (b).

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

C++ language

(a) Given three positive numbers x, y and z, we can determine if these are the lengths
of a triangle by checking that the following inequalities hold simultaneously:
z < x + y
x < y + z
y < z + x.
Write a function which implements the above idea. Its exact declaration should be:
bool is_triangle(double x, double y, double z)
The function should contain no cout statements.
Here are Some test cases:
• is triangle(0,0,0) → false
• is triangle(-1,1,1) → false
• is triangle(1,1,10) –→ false
• is triangle(1,10,1) → false
is triangle (1,1,1) → true
• is triangle(2,13,12) + true
(b) Write a function which computes the area of a triangle given three side lengths via
Heron's formula: https://en.wikipedia.org/wiki/Heron%27s_formula
Assume that the side lengths form a valid triangle. Its exact declaration should be:
double area(double x, double y, double z)
The function should contain no cout statements.
Here are some test cases:
• area (1,1,1) → 0.433013
• area(2,13,12) → 10.7906
• area(12,13,2) → 10.7906
(c) Write a main function which reads three double values from the standard input. If
the values are the side lengths of a triangle, the program should print:
The values 3.0, 4.0 and 5.0 are the side lengths of a triangle with area
6.0.
Otherwise:
The values 1.1, 2.0 and 5.0 are not the side lengths of a triangle.
All floating point values should be printed with 6 digits of precision. For full credit,
the main function must call the functions from (a) and (b).
Transcribed Image Text:(a) Given three positive numbers x, y and z, we can determine if these are the lengths of a triangle by checking that the following inequalities hold simultaneously: z < x + y x < y + z y < z + x. Write a function which implements the above idea. Its exact declaration should be: bool is_triangle(double x, double y, double z) The function should contain no cout statements. Here are Some test cases: • is triangle(0,0,0) → false • is triangle(-1,1,1) → false • is triangle(1,1,10) –→ false • is triangle(1,10,1) → false is triangle (1,1,1) → true • is triangle(2,13,12) + true (b) Write a function which computes the area of a triangle given three side lengths via Heron's formula: https://en.wikipedia.org/wiki/Heron%27s_formula Assume that the side lengths form a valid triangle. Its exact declaration should be: double area(double x, double y, double z) The function should contain no cout statements. Here are some test cases: • area (1,1,1) → 0.433013 • area(2,13,12) → 10.7906 • area(12,13,2) → 10.7906 (c) Write a main function which reads three double values from the standard input. If the values are the side lengths of a triangle, the program should print: The values 3.0, 4.0 and 5.0 are the side lengths of a triangle with area 6.0. Otherwise: The values 1.1, 2.0 and 5.0 are not the side lengths of a triangle. All floating point values should be printed with 6 digits of precision. For full credit, the main function must call the functions from (a) and (b).
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Concept of Parenthesis
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education