Pages

Wednesday, 20 March 2019

Program to print grade of student as given marks in 5 subject

import java.util.*;
class students
{
public static void main (String args [])
{
int m1,m2,m3,m4,m5,tm;
double per;
Scanner sc= new Scanner (System.in);
System.out.println ("Enter the marks of 5 subject");
m1= sc.nextInt ();
m2= sc.nextInt ();
m3= sc.nextInt ();
m4= sc.nextInt ();
m5= sc.nextInt ();
tm= m1+m2+m3+m4+m5;
per=(tm/500.0)*100;
 if (per>=80)
  {
      System.out.println (per+"A");
  }
    else if (per>=70 && per<80)
  {
   System.out.println (per+"B");
  }
   else if (per>=60 && per<70)
   {
   System.out.println (per+"C");
   }
   else if (per>=60 && per<50)
    {
      System.out.println (per+"D");
    }
   else
   {
   System.out.println (per+"Fail");
   }
   }
   }

No comments:

Post a Comment