Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a Java program that reads in letter grades for a class of students. Acceptable grades are A,B,C,D, and F. The user may enter as
Write a Java program that reads in letter grades for a class of students. Acceptable grades are A,B,C,D, and F. The user may enter as many grades as desired and enters a Z to indicate the end of the grades. The terminating letter Z does not count as a grade. The user should not attach a plus or minus to a grade. The program should keep track of any other characters entered by the user, but these non-grade characters will not participate in any calculations. Your program should treat a lower-case letter like its upper-case equivalent; for example, process a b as if it were a B. If letter is a char variable, the statement letter = Character ,toUpperCase ( letter );// Capitalize the letter, if possible will capitalize the character if is an alphabetic letter. The program should keep track of the number of students that passed (D or above) and the number that failed (F). After the user finishes entering the letter grades, the program should calculate and print the percentage of students passing and failing as well as the class grade-point average (GPA). Use the following numeric values for computing the class GPA: A=4.0,B=3.0,C=2.0,D=1.0, and F=0.0. Letter grades of A or B are worthy of the Honor Roll. The program should report the number of Honor Roll-worthy grades. Any letters that the user enters that are not A,B,C,D, or F do not participate in the calculation of the pass/fail percentage and do not contribute to the GPA calculation. If the user enters a Z before entering any valid letter grades, the program should terminate without printing anything. The program should report the number of non-grade characters the user supplied even though it otherwise ignores them. The terminating Z is a valid end marker and it does not count as a bad character. The following shows a sample run of the program: Enter grades ( z terminates the list): A b B C T F D z Students passing: 5(83.333%) Students failing: 1 (16.6678) Students on Honor Roll: 3 Number of ignored entries: 1 Class GPA: 2.167 The grades do not have to all be in a single line; for example, the following shows another sample run showing that the user can separate the grades by either spaces or newlines (that is, pressing the enter key): Enter grades ( z terminates the list): c C a A F b A z Students passing: 6 (85.714\%) Students failing: 1 (14.286\%) Students on honor roll: 4 Number of ignored entries: 0 Class GPA: 2.714 The program thus ignores spaces and new lines, except to serve as separating one character from another. Your program should report the percentages and GPA rounded to three decimal places as shown above. Strategy A reasonable strategy is to count the number of As,B s, etc. as integer quantities (for example, you can have 12B s or 13B s, but your program won't see 12.4 Bs in the sequence). You can keep track of the number of non-grade characters and number of honor roll grades in a similar fashion. Once your program has read in all the data and has all the counts, your program then can use the counts to compute the passing and failing percentages and the GPA
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