Question: Java Write a program that reads three numbers from keyboard, and then prints out some information about the relationships between the numbers - whether they

Java

Write a program that reads three numbers from keyboard, and then prints out some information about the relationships between the numbers - whether they are all equal, in ascending order, in descending order, and so on.

To determine these relationships, write the following boolean-valued functions:

boolean allAreEqual(int a, int b, int c);

boolean twoAreEqual(int a, int b, int c); // false if all three are equal

boolean noneAreEqual(int a, int b, int c);

boolean areAscending(int a, int b, int c); // true if a <= b <= c

boolean areDescending(int a, int b, int c); // true if a >= b >= c

boolean strictlyAscending(int a, int b, int c); // true if a < b < c

boolean strictlyDescending(int a, int b, int c); // true if a > b > c

Try to "talk boolean" i.e., use boolean variables and conditional operators rather than if statements where possible

For example, write:

boolean isNegative = x < 0;

rather than:

boolean isNegative;

if (x i< 0)

isNegtive = true;

else

isNegative = false;

Below is hw the output should look:

first number? 1

second number? 2

third number? 3

allAreEqual: false

twoAreEqual: false

noneAreEqual: true

areAscending: true

areDescending: false

strictlyAscending: true

strictlyDescending: false

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!