Write a Java program that determines a student’s grade

if the average score >=90% =>Student grade = A

if the average score >= 70% and <90% =>Student grade = B

if the average score>=50% and <70% =>Student grade = C

if the average score<50% =>Student grade = F

Introduction

In this demo I have used NetBeans IDE 8.2 for debugging purpose. But you can use any java programming language compiler as per your availability..

import java.util.*;
public class JavaExcercise
{
public static void main(String[] args)
{
showGrade();
}
 
static void showGrade(){
 
    float quiz_score, mid_score,final_score,avg;
    Scanner sc=new Scanner(System.in);
    System.out.print("Enter you quiz score:");
    quiz_score=sc.nextFloat();
    System.out.print("Enter your Mid-term score:");
    mid_score=sc.nextFloat();
    System.out.print("Enter your Final score:");
    final_score=sc.nextFloat(); 
    avg=(quiz_score+mid_score+final_score)/3;
 
    if(avg>=90) System.out.println("Your grade A.");
    else if((avg>=70) && (avg<90)) System.out.println("Your grade B.");
    else if((avg>=50) && (avg<70)) System.out.println("Your grade C.");
    else if(avg<50) System.out.println("Your grade F.");
    else System.out.println("Invalid");
 
 
    }
 
}

Result

Write a Java program that determines a student’s grade
Write a Java program that determines a student’s grade

Leave a Comment