Answered step by step
Verified Expert Solution
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started