Question: Write a program that reads in two double numbers followed by an integer (say n) The goal of the program is to check if the

Write a program that reads in two double numbers followed by an integer (say n) The goal of the program is to check if the two numbers are equal to n significant digits (See Sec 3.2 Common Error 3.2 on page 87 of textbook). input The input will be one or more lines of three numbers. The first two numbers are doubles and represent the two numbers that are to be compared. The third number is an integer and represents the number of significant digits to check (for equality of the two numbers). Output The output will show the difference up to 10 decimal places (as shown in sample output) and then whether the numbers are equal or not. Sample Input 1.112 1.113 2 1.123 1.124 3 Sample Output difference0.0010000000, Numbers are equal to 2 decimal places difference 0.0010000000 , Numbers are not equal to 3 decimal places HINT 1. To print difference to 10 decimal places use System.out.printf("96.10f", diff); 2. Compare difference of numbers against 1.0/ Math.pow(10, n) where, n is the integer being read in by the program. 3. Make sure to take the absolute value of the difference when you compare. Use Math.abs method to get the absolute value
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
