Ground rules for this task: • You can only use Boolean operators, numerical comparisons, and the abs function. • You cannot use any conditional (i.e., if) statements. A right triangle is a triangle in which one angle measures 90 degrees. There is a simple test to figure out whether a triangle is a right triangle: 1. Let c be the length of the longest side, and a and b be the lengths of the other two sides. 2. If c² = a² + b², we know that the triangle is a right triangle; otherwise, it is not. %3D For this problem, three parameters–x: float, y: float, z: float-have been set by the grader before your program begins. They are the lengths of the three sides of a triangle, in no particular order. Your task is to write a program that implements the test as described above so that when the finished, the variable right_triangle: bool correctly indicates whether the side lengths, as given, make up a right triangle. program is

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter1: Fundamentals Of C++ Programming
Section1.3: Preliminary Three: Software Development
Problem 7E: (Statistics) This is the formula for the standard normal deviate, z, used in statistical...
icon
Related questions
Question
100%

Create right triangle without any statements (i.e.IF conditions.)

Floating-Point Warning: Because of how computers represent floating-point numbers, it is impos-
sible to test whether two floating numbers have the exact same numerical value. Hence, when r and s
are floating-point numbers, writing s
meaningless. A much better way to test for equality is to use the test
r to test if they have the same numerical value is generally
=3=
abs(s
r) < T
where T is a "threshold" number, below which we deem two numbers identical. For this problem, use
T = 10-7. In Python, we can write 10- simply as le-7, hence writing abs(s - r) < 1e-7.
%3D
Examples:
• x=4.0, y=5.0, z=3.0 gives right_triangle=True.
• x=11.5, y=5.0, z=3.0 gives right_triangle=False.
Transcribed Image Text:Floating-Point Warning: Because of how computers represent floating-point numbers, it is impos- sible to test whether two floating numbers have the exact same numerical value. Hence, when r and s are floating-point numbers, writing s meaningless. A much better way to test for equality is to use the test r to test if they have the same numerical value is generally =3= abs(s r) < T where T is a "threshold" number, below which we deem two numbers identical. For this problem, use T = 10-7. In Python, we can write 10- simply as le-7, hence writing abs(s - r) < 1e-7. %3D Examples: • x=4.0, y=5.0, z=3.0 gives right_triangle=True. • x=11.5, y=5.0, z=3.0 gives right_triangle=False.
Ground rules for this task:
• You can only use Boolean operators, numerical comparisons, and the abs function.
• You cannot use any conditional (i.e., if) statements.
A right triangle is a triangle in which one angle measures 90 degrees. There is a simple test to figure
out whether a triangle is a right triangle:
1. Let c be the length of the longest side, and a and b be the lengths of the other two sides.
2. If c2 = a? + b², we know that the triangle is a right triangle; otherwise, it is not.
а
For this problem, three parameters-x: float, y: float, z: float–have been set by the grader
before your program begins. They are the lengths of the three sides of a triangle, in no particular order.
Your task is to write a program that implements the test as described above so that when the program is
finished, the variable right_triangle: bool correctly indicates whether the side lengths, as given,
make up a right triangle.
Transcribed Image Text:Ground rules for this task: • You can only use Boolean operators, numerical comparisons, and the abs function. • You cannot use any conditional (i.e., if) statements. A right triangle is a triangle in which one angle measures 90 degrees. There is a simple test to figure out whether a triangle is a right triangle: 1. Let c be the length of the longest side, and a and b be the lengths of the other two sides. 2. If c2 = a? + b², we know that the triangle is a right triangle; otherwise, it is not. а For this problem, three parameters-x: float, y: float, z: float–have been set by the grader before your program begins. They are the lengths of the three sides of a triangle, in no particular order. Your task is to write a program that implements the test as described above so that when the program is finished, the variable right_triangle: bool correctly indicates whether the side lengths, as given, make up a right triangle.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning