Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java application that will: Welcome the user Ask the user with prompts to enter integers (see the sample below) Read 4 integers into

Write a Java application that will:

Welcome the user

Ask the user with prompts to enter integers (see the sample below)

Read 4 integers into the program (no integers will be duplicates when tested)

Determine largest integer in the group using the compound && operator

By utilizing the compound "and" you can join multiple expressions. In Java you can do this using the && operator.

For example, to check if number1 greater than number2 and that number1 is greater than number3 use the following: if (number1 > number2 && number1 > number3) {

Then number 1 is the largest of the 3

} else {

Test to see if number2 is the largest using the same technique.

} else {

Test for number3

}

Determine smallest integer in the group using the techniques shown in the lectures standalone ifs.

For example:

smallest = firstNumber

If secondNumber is smaller than the first then {

smallestNumber = secondNumber

}

Now test the third etc.

6. Print the largest and smallest numbers with appropriate text

Use the % operator to determine if the smallest number is a factor or is not a factor of the largest.

Remembera number is a factor of another number if the first number can divide into the second number with no remainder.

Using the % (modulo) operator: largest % smallest should equal 0 if the smallest is a factor

Print with appropriate text whether or not the smaller is a factor of the larger

Calculate and display to 4 decimals the value of the largest number divided by the smallest number.

Remember to get a decimal answer when dividing integers you must cast one of the ints to a double or the decimal answer will be discarded

Only one of the integers should be cast

Use this guide: remainder = (double) largest / smallest;

Thank the user for using the software

Sample output

image text in transcribed

Welcome to the Number Manipulator Please enter 4 integers separated by a space or on separate lines: 26 120 3317 17 is the smallest number. 120 is the biggest number. 17 is not a factor of 120 . 120 divided by 17 is 7.0588 Thank you for using the Number Manipulator

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

Question

What is a modem?

Answered: 1 week ago

Question

1. Define mass and mediated communication

Answered: 1 week ago