Question: Write a program to test whether an integer n equals 10 and whether a floating-point number is approximately equal to 10. (In Java) Hints: You

Write a program to test whether an integer n equals 10 and whether a floating-point number is approximately equal to 10. (In Java)

Hints:

You could do this by prompting the user for an integer. Then see if that integer equals 10. Display on the screen "## is (not) equal to 10" where ## is the number the user typed in. Create a double variable y that is equal to the user's integer divided by a number (2, 3, or 4 would be good choices). Display on the screen "## divided by 2 is ..." (use the user's integer, and your chosen number, and display the quotient). You could accomplish this with something like System.out.println("## divided by 2 is " + y);

Multiply the quotient y by your number and see if the result is equal to 10. Use the EPSILON constant we discussed in class (see "Common Error 3.2" on page 91) to make this determination. Display on the screen "## is (not) equal to 10" where ## is the quotient times 2 (or whatever number you chose to use).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!