In: Computer Science
Develop a program Grades.java that collects the user's (students) name, course name, and the score for three quizzes. You are supposed to read this data from the keyboard using the Scanner class. Calculate the total score and the average score.
Further, using the grading scale below, based on the average score computed above, your program should calculate and output a letter grade. and the range boundaries should be configured properly (i.e.: exactly 90 and above is an A, and anything less than 90 to exactly 80 is a B). The grading scale to use is as follows:
Letter Category |
Average Score Range |
A | 90 - 100 |
B | 80 - 90 |
C | 70 - 80 |
D | 60 - 70 |
E | 0 - 60 |
Note: The E Category is not a typo.
Declare the variables in the order studName, courseName, scoreQuiz_1, scoreQuiz_2, and scoreQuiz_3, totalScore, averageScore, and letterCategory. Make sure you declare the variables studName, courseName, and letterEvaluation as String class variables. Select proper data type for the variables totalScore and averageScore. The data type should support decimals. Use a constant variable NUM_OF_Quizzes to compute the average score.
Things to watch for: As you are determining your logic for your if statements in this project, consider that a percentage of 90.0 results in an A, 89.8 results in a B category, 79.12 results in a C category, and 69.994949 results in a D category. That last example is a bit extreme, but the idea is to not try to predict how many 9s after the decimal you need to account for. Just think of where the last boundary ends and where the next one begins, and how you might use your mathematical operators to account for that (is it less-than-or-equal-to, or just less than?).
Formatting: Import the package DecimalFormat to format the average score data. You do this by typing: import java.text.DecimalFormat; either below or above the line: import java.util.Scanner;
Then create a DecimalFormat object by typing: DecimalFormat df = new DecimalFormat("##.00"); either above or below the line Scanner scnr = new Scanner(System.in);
A format with 2 digits would be displayed by using the df as follows:
System.out.println("The average score is: "+df.format(averageScore));
Pseudocode: Prior to writing the Java code for the project, develop a document in pseudocode that outlines how the program will flow. Remember that there are no specific rules regarding pseudocode, but rather you should write pseudocode in a way that is human-readable and understandable (English for this assignment).
The following example is what your program might look like:
____________________________________________________________________________________
Your Score Card for Three Quizzes
Please enter your name : Julie Kimbal
Please enter your course you are taking : CS1400 Fundamentals of Programming
Please enter the score for quiz 1 : 77
Please enter the score for quiz 2 : 85
Please enter the score for quiz 3 : 79
The total score is 241.0
The average score is : 80.33
Thanks Julie Kimbal. Your grade for the 3 quizzes in CS1400 Fundamentals of Programming is a (n) B.
________________________________________________________________________________________________________________________
Experiment cases: Make sure that your program computes correct average scores for the following experiment cases:
Quiz 1 | Quiz 2 | Quiz 3 | Average | Category | |
Experiment case 1 | 67 | 58 | 54 | 59.67 | E |
Experiment case 2 | 78 | 71 | 83 | 77.33 | C |
Experiment case 3 | 89 | 90 | 93 | 90.67 | A |
You need to upload three files:
Thanks for the question. Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks! =========================================================================== import java.text.DecimalFormat; import java.util.Scanner; public class Grades { public static void main(String[] args) { //studName, courseName, String studName, courseName; // scoreQuiz_1, scoreQuiz_2, and scoreQuiz_3, int scoreQuiz_1, scoreQuiz_2, scoreQuiz_3; // totalScore, averageScore, double totalScore, averageScore; // and letterCategory char letterCategory; //NUM_OF_Quizzes final int NUM_OF_QUIZZES = 3; //Then create a DecimalFormat object DecimalFormat df = new DecimalFormat("##.00"); //either above or below the line Scanner scnr = new Scanner(System.in); Scanner scnr = new Scanner(System.in); System.out.println("Your Score Card for Three Quizzes"); System.out.print("Please enter your name: "); studName = scnr.nextLine(); System.out.print("Please enter your course you are taking : "); courseName = scnr.nextLine(); System.out.print("Please enter the score for quiz 1: "); scoreQuiz_1 = scnr.nextInt(); System.out.print("Please enter the score for quiz 2: "); scoreQuiz_2 = scnr.nextInt(); System.out.print("Please enter the score for quiz 2: "); scoreQuiz_3 = scnr.nextInt(); totalScore = (scoreQuiz_1 + scoreQuiz_2 + scoreQuiz_3); averageScore = totalScore / NUM_OF_QUIZZES; if (averageScore >= 90) letterCategory = 'A'; else if (averageScore >= 80) letterCategory = 'B'; else if (averageScore >= 70) letterCategory = 'C'; else if (averageScore >= 60) letterCategory = 'D'; else letterCategory = 'E'; // display output System.out.println("The total score is " + df.format(totalScore)); System.out.println("The average core is : " + df.format(averageScore)); System.out.println("Thanks " + studName + ". Your grade for the 3 quizzes in " + courseName + " is a(n) " + letterCategory); System.out.println(); } }
===================================================================