Prepare grade stars

This Extra Credit assignment builds on the Grade Stars app done in week 7. It adds looping to the application so that a grade can be continually input until the user signals that they want to quit. Aside from the requirements from the Grade Stars assignment, these are additional and clarified requirements:

1. The prompt for input asks for a letter grade from A to F (inclusive), with the additional wording, “or press Enter with no input to quit.”

2. Only single grade letters, upper or lower case, are considered valid. Input exceeding a single character is invalid and should cause an Error JOptionPane dialog, complete with the appropriate icon and title of “Error” at the top of the window. (Note: this does not change default input and output from using a Scanner, only the error message. Do not do this in your real apps, i.e., mixing output modes.)

o Use the trim() method on the input so leading/trailing whitespace is removed, e.g., an input of ” B” should still be considered valid.

3. An empty input string causes the loop and program to exit, otherwise it outputs the number of stars for the grade, or error message, and then re-prompts for the next letter grade.

4. The program must exit at the bottom of main, not from within the loop.

5. Please insure your indentation of original code/logic is correct and clearly shows as being within a looping structure!
You can base this V2 app on your own code (recommended) or use the posted solution if you wish. Anyone can submit for this extra credit, regardless of score on Grade Stars.

Here is some short pseudocode of one way to look at this.
prompt for grade input
while grade input length > 0
do Grade Stars V1 (+ check for input length == 1 and error message enhancement)
prompt for grade input

Name this program/class GradeStarsV2<XW>. Submit just the single .java file to this dropbox. You may make as many submissions as you like, but I will only grade the last submission after the assignment Due Date. There will not be any feedback given on this prior to assessment for the grade, so make sure to read and understand the requirements clearly. If there are any questions, please post them in the Assignments forum!

Leave a Reply

Your email address will not be published.