Q:

Write a Java aprogram to determine a student grade

0

Write a Java aprogram to determine a student’s grade. 

The program will read three types of scores (quiz score, mid-term score, and final score), 

calculate the total score and determine the grade based on the following rules:

if the total score >= 90 grade=A

if the total score >= 70 and < 90 grade=B

if the total score >= 50 and < 70 grade=C

if the total score < 50 grade=F

[total score = quiz score + mid-term score + final score]

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int quiz_mark, mid_term_mark, final_mark, total_marks=0;  
char grade;   
System.out.println("Enter the Quiz Score: ");
quiz_mark = input.nextInt(); 
System.out.println("Enter the Mid Exam Score: ");
mid_term_mark = input.nextInt(); 
System.out.println("Enter the Final Score: ");
final_mark = input.nextInt();
total_marks = quiz_mark + mid_term_mark + final_mark; 
System.out.println("Total Score=" + total_marks); 
if (total_marks >= 90)  
    grade = 'A';
else if ((total_marks >= 70) && (total_marks < 90)) 
        grade = 'B';
else if ((total_marks >= 50) && (total_marks < 70)) 
        grade = 'C';
else
    grade = 'F';
    
System.out.println("The grade is " + grade); 
	}
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now