Question: Java application IntegerAndDouble After prompting for the integer, your program must check the next input token: If it is not an integer, then display a

Java application IntegerAndDouble

After prompting for the integer, your program must check the next input token: If it is not an integer, then display a message and terminate the program. Do the same for the double number.

You must use one Scanner object and call Scanner methods to process input. You cannot use the try-catch statement or call any parse method.

Before calculating the square root, your program must check the double number: If it is negative, then display a message; otherwise, calculate and display the square root. Before calculating the quotient divided by the double number, your program must check the double number: If it is zero, then display a message; otherwise, calculate and display the quotient.

Before calculating the quotients and remainder divided by the integer part of the double number, your program must check the integer part of the double number: If it is zero, then display a message; otherwise, calculate and display the quotients and remainder.

The square root is displayed with 4 decimal digits, the quotient divided by the double number is displayed with 3 decimal digits, and the quotient divided by the integer part of the double

number is displayed with 2 decimal digits.

Sample output I

Enter an integer: 5a 5a is not an integer! Program terminated! Sample output II

Enter an integer: 5 The integer number is 5. Enter a double number: notadouble notadouble is not a double number! Program terminated!

Sample output III

Enter an integer: 5 The integer number is 5. Enter a double number: -3.3 The double number is -3.3. No square root, since the double number is negative. The quotient of the integer number divided by the double number is -1.515. The integer part of the double number is -3. The double quotient of the integer number divided by the integer part of the double number is -1.67. The integer quotient of the integer number divided by the integer part of the double number is -1. The remainder of the integer number divided by the integer part of the double number is 2.

Sample output IV

Enter an integer: 21 The integer number is 21. Enter a double number: 0.5 The double number is 0.5. The square root of the double number is 0.7071. The quotient of the integer number divided by the double number is 42.000. The integer part of the double number is 0. No quotients or remainder, since the integer part of the double number is zero.

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!