Computer Science, asked by advay4, 8 months ago

Write a program in Java to input student's name, class, roll number and marks in [t
5 subjects. Compute the total marks, percentage and grade as per the following
table:
Grade
Percentage
Greater than or equal to 90-A
Greater than or equal to 70 but less than 90-B
Greater than or equal to 50 but less than 70-C
Greater than or equal to 40 but less than 50-D
Less than 40-E

Answers

Answered by rohitkhajuria90
4

Please refer the attached image

Attachments:
Answered by mad210202
4

Answer:

The program has above code:

Explanation:

import java.util.Scanner;

 

class FindGrade

{

//get student name class roll number and marks of student and calculate percentage and grade

public static void main(String args[])

{

 int sub[],i,total=0,cls;

 float per=0.0f;

 Scanner sc;

 String rNo, na;

       

 

 sub=new int[5];

 sc=new Scanner(System.in);

               System.out.println("Enter Name");

               na=sc.next();

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

               cls=sc.next();

 System.out.println("Enter Roll Number");

 rNo=sc.next();

 

 for(i=0;i<5;i++)

 {

  System.out.println("Enter Marks Of Subject "+(i+1));

  sub[i]=sc.nextInt();

  total=total+sub[i];

 }

 

 per=total*100/500;

 

 System.out.println("\n***** Details Of Student *****\n");

 System.out.println("\nName "+na);

               System.out.println("\nClass "+cls);

 System.out.println("\nRoll Number "+rNo);

 System.out.println("Total Marks Gained Is "+total);

 System.out.println("Percentage Gained Is "+per);

 

 if(per>90) {

  System.out.println("Your Grade Is A");

                }

 else if(per>70 && per<90) {

  System.out.println("Your Grade Is B");

                }

 else if(per>50 && per<70) {

  System.out.println("Your Grade Is C");

                }

 else if(per>40 && per<50) {

  System.out.println("Your Grade Is D");

 }

 else

                  {

  System.out.println("Your Grade Is E");

}            }

}

Similar questions