Search for question
Question

14.4 Homework 2 P1: Comparing doubles

Write a program that is given two doubles for comparison and a third double that is a difference threshold, called epsilon. Output one of

three phrases:

output "equal" if the doubles are within 0.001 (exclusively) of each other

• output "close enough" if the doubles are within epsilon (exclusively) of each other

output "not close" if doubles are not within epsilon

e

Note: End each output statement with a newline. Hint: use fabs() to find the absolute value of the difference between the two numbers.

Ex: If the input is:

14.1 14.2 0.2

Fig: 1