Computer Science, asked by abhishekyadav0223, 12 hours ago

WAP to print the grade of a student from the 5 marks entered by the user. More than 80% - Distinction More than 60% - First Class More than 40% - Second class Otherwise, fail.​

Answers

Answered by ItzMeSam35
1

import java.util.Scanner;

public class Grade

{

public static void main(String args[])

{

double m1 , m2 , m3 , m4 , m5 ;

double mP ;

Scanner sc = new Scanner(System.in);

System.out.print("Please enter the marks of first subject : ");

m1 = sc.nextDouble();

System.out.print("Please enter the marks of second subject : ");

m2 = sc.nextDouble();

System.out.print("Please enter the marks of third subject : ");

m3 = sc.nextDouble();

System.out.print("Please enter the marks of fourth subject : ");

m4 = sc.nextDouble();

System.out.print("Please enter the marks of fifth subject : ");

m5 = sc.nextDouble();

mP = ( m1 + m2 + m3 + m4 + m5 ) / 500 * 100 ;

if (mP >= 80)

{

System.out.println("Distinction");

}

else if (mP >= 60 && mP < 80)

{

System.out.println("First Class");

}

else if (mP >= 40 && mP < 60)

{

System.out.println("Second Class");

}

else

{

System.out.println("Fail");

}

sc.close();

}

}

Similar questions