Sale!

COSC 1046 Assignment 2

$30.00 $18.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (3 votes)

Question 1 (GradeCalculator.java)
Write a program that prompts the user to enter three number grades (doubles are probably best here). The
program computes the average of the three grades and displays the letter grade for the average. Letter
grades are computed as follows (this requires if-statements):
 A+: 90-100
 A: 80-89
 B: 70-79
 C: 60-69
 D: 50-59
 F: < 50 C:\Users\aaron\Desktop>java GradeCalculator
Please enter three grades: 60 80 100
Average grade: 80 or A
End of program.
C:\Users\aaron\Desktop>java GradeCalculator
Please enter three grades: 75.5 81.3 19.7
Average grade: 58.83 or D
End of program.
Since most grades are between 0 (#sadfaceemoji) and 100 (#highfivegif) we shouldn’t proceed with the
program if any of the grades are outside of that range. If any of the grades are < 0 or > 100, stop the program
with an appropriate message.
C:\Users\aaron\Desktop>java GradeCalculator
Please enter three grades: -75.5 81.3 19.7
One of the grades is out of range.
End of program.
C:\Users\aaron\Desktop>java GradeCalculator
Please enter three grades: 75.5 81.3 119.7
One of the grades is out of range.
End of program.
C:\Users\aaron\Desktop>java GradeCalculator
Please enter three grades: 75.5 81.3 19.7
Average grade: 58.83 or D
End of program.
Question 2.
(StringChecker.java) Write a program that collects three Strings from the user. Determine and display
whether the strings are all equal, in increasing or decreasing lexicographical (alphabetical) order or not in any
specific order at all.
(Hint: If you are having a hard time getting this to work with Strings try it with integers first. The logic is the same
but the syntax is a bit different.)
C:\cosc1046\a2\>java StringChecker
Enter 3 strings, one per line:
apples
bananas
coconuts
Your strings are in lexicographical order (ascending) !
C:\cosc1046\a2\>java StringChecker
Enter 3 strings, one per line:
coconuts
bananas
apples
Your strings are in lexicographical order (descending) !
C:\cosc1046\a2\>java StringChecker
Enter 3 strings, one per line:
apples
apples
bananas
Your strings are in lexicographical order (ascending) !
C:\cosc1046\a2\>java StringChecker
Enter 3 strings, one per line:
apples
coconuts
bananas
Those strings are not in any order 🙁
C:\cosc1046\a2\>java StringChecker
Enter 3 strings, one per line:
apples
apples
apples
The strings are equal.
DO NOT SUBMIT THE FOLLOWING QUESTIONS
Question 3 (SimpleMath.java)
Collect two integer values from the user. Based on these values display the sum, difference, product, average,
distance (absolute difference), maximum and minimum. Sample output is provided below:
C:\Users\aaron\Desktop>java SimpleMath
Enter two integers:
10
20
Sum:30
Difference:-10
Product:200
Average:15.0
Distance:10
Maximum:20
Minimum:10
C:\Users\aaron\Desktop>java SimpleMath
Enter two integers:
101 52
Sum:153
Difference:49
Product:5252
Average:76.5
Distance:49
Maximum:101
Minimum:52
Do the same work outlined above BUT have the output aligned in the following manner:
C:\Users\aaron\Desktop>java SimpleMath
Enter two integers:
101 52
Sum: 153
Difference: 49
Product: 5252
Average: 76.5
Distance: 49
Maximum: 101
Minimum: 52