Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a class called TwoNumbers which will ask the user for two double numbers and print out comments based on their values. There is no

image text in transcribed

Write a class called TwoNumbers which will ask the user for two double numbers and print out comments based on their values. There is no starter file and you will write all the code. Use this exact prompt to get input: System.out.print("Enter two numbers (like this: 41.7 -22.5): "); The user can enter both numbers on the same line at the same time. This is possible because the first call to nextDouble will skip any leading whitespaces and then read up to the next whitespace (the space), leaving that whitespace in the input stream. The second call to nextDouble will ignore leading whitespaces and then read up to the next whitespace (the newline) leaving the newline in the input stream. This is a handy way to request multiple inputs. Here are the conditions and the comments to print. Comment Condition ||first is equal to second first is greater than second first is less than second the numbers are within .0001 of each other the numbers are more that 10000 apart they have the same sign/different sign The first number is equal to the second The first number is greater than second The first number is less than second The numbers are close together The numbers are far apart The numbers have the same/different sign If the numbers are equal only print the one message. Otherwise print all that apply in the order given above. Copy and paste the prompt and the replies. That way you will have exactly what Codecheck expects. Use the appropriate if structure and do not just use all ifs. Note for advanced students: Do not use System.exit()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions