Write a Java program that determines a student’s grade. The program will read three types ofscores(quiz, mid-term, and final scores) and determine the grade based on the following rules: -if theaverage score >=90% =>grade=A -if the average score >= 70% and <90% => grade=B -if theaverage score>=50% and <70% =>grade=C -if the average score<50% =>grade=F
Question
Write a Java program that determines a student’s grade. The program will read three types ofscores(quiz, mid-term, and final scores) and determine the grade based on the following rules: -if theaverage score >=90% =>grade=A -if the average score >= 70% and <90% => grade=B -if theaverage score>=50% and <70% =>grade=C -if the average score<50% =>grade=F
Solution
Sure, here is a step-by-step solution in a programming language:
- Start by declaring variables to store the quiz, mid-term, and final scores.
- Read the quiz score from the user and store it in the respective variable.
- Read the mid-term score from the user and store it in the respective variable.
- Read the final score from the user and store it in the respective variable.
- Calculate the average score by adding the quiz, mid-term, and final scores and dividing the sum by 3.
- Use conditional statements to determine the grade based on the average score:
- If the average score is greater than or equal to 90, assign the grade "A".
- If the average score is greater than or equal to 70 and less than 90, assign the grade "B".
- If the average score is greater than or equal to 50 and less than 70, assign the grade "C".
- If the average score is less than 50, assign the grade "F".
- Print the grade to the console.
Here is an example implementation in Java:
import java.util.Scanner;
public class GradeCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter quiz score: ");
int quizScore = scanner.nextInt();
System.out.print("Enter mid-term score: ");
int midTermScore = scanner.nextInt();
System.out.print("Enter final score: ");
int finalScore = scanner.nextInt();
double averageScore = (quizScore + midTermScore + finalScore) / 3.0;
String grade;
if (averageScore >= 90) {
grade = "A";
} else if (averageScore >= 70) {
grade = "B";
} else if (averageScore >= 50) {
grade = "C";
} else {
grade = "F";
}
System.out.println("Grade: " + grade);
}
}
This program prompts the user to enter the quiz, mid-term, and final scores, calculates the average score, and determines the grade based on the average score. Finally, it prints the grade to the console.
Similar Questions
Java Program To Accept the Marks of a Student and Find the Total Marks and Percentage
Check the following Java program carefully. What should be written in the blank? Choose from the given options. public class Test { public static void main(String[] args) { System.out.print("The grade is " + getGrade(78.5)); System.out.print("\nThe grade is " + getGrade(59.5)); } public static ________ getGrade(double score) { if (score >= 90.0) return 'A'; else if (score >= 80.0) return 'B'; else if (score >= 70.0) return 'C'; else if (score >= 60.0) return 'D'; else return 'F'; }}Group of answer choicesvoidStringintchar
using the while loop, and scenner draft a java code that grades students when they enter makes it grades it with A,B+,B,C,C+ and F grades
As a python student, write a program using functions and conditions to display the grades that the students will be receiving. The grades are:90% - 100% Grade is A 80% - 89% Grade is B70% - 79% Grade is C 60% - 69% Grade is D 50% - 59% Grade is E <50% Fail
Problem StatementA computer science teacher assigned the students a programming task that calculates and displays grades based on test marks. The teacher wants the program to take a student's test mark as input and determine their grade using the following criteria:If the mark is between 90 and 100 (inclusive), assign grade A.If the mark is between 80 and 89 (inclusive), assign grade B.If the mark is between 70 and 79 (inclusive), assign grade C.If the mark is between 60 and 69 (inclusive), assign grade D.If the mark is between 45 and 59 (inclusive), assign grade E.For marks below 45 assign grade F.If the mark is greater than 100 or a negative number, it displays "Invalid input". Help the students to accomplish the given task.Note: This question helps in clearing AMCAT exam.Input format :The input consists of a single integer, representing the student's mark.Output format :The output displays "Grade: " followed by the grade for the given mark based on the given criteria.If the mark is greater than 100 or a negative number, the output displays "Invalid input".Refer to the sample output for the formatting specifications.Code constraints :In the given scenario, the test cases fall under the following constraints:0 ≤ student's mark ≤ 100Sample test cases :Input 1 :100Output 1 :Grade: AInput 2 :85Output 2 :Grade: BInput 3 :79Output 3 :Grade: CInput 4 :63Output 4 :Grade: DInput 5 :56Output 5 :Grade: EInput 6 :0Output 6 :Grade: FInput 7 :-5Output 7 :Invalid inputInput 8 :126Output 8 :Invalid input
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.