Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Write a program that reads three numbers from the file numbers.text, and then prints out some information about the relationships between the numbers -

Java

Write a program that reads three numbers from the file numbers.text, 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

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

Beginning PostgreSQL On The Cloud Simplifying Database As A Service On Cloud Platforms

Authors: Baji Shaik ,Avinash Vallarapu

1st Edition

1484234464, 978-1484234464

More Books

Students also viewed these Databases questions