The marks obtained by a student in 6 different subjects are input through the
keyboard and calculate division as per the following rules:
· Percentage above or equals to 70 - Distinction Class
· Percentage between 60 to 69 – First Class
· Percentage between 50 to 59 – Second Class
· Percentage between 40 to 49 – Third Class
· Percentage less than 40 – Fail
WAP to calculate the class obtained by the student.
import java.io.DataInputStream;
public class StudentGrade
{
public static void main(String[] args)
{
int m1,m2,m3,m4,m5,m6,sum;
double per;
try
{
DataInputStream s1=new DataInputStream(System.in);
System.out.println("Enter The All Subject Marks:-");
System.out.print("Subject 1 :->");
m1=Integer.parseInt(s1.readLine());
System.out.print("Subject 2 :->");
m2=Integer.parseInt(s1.readLine());
System.out.print("Subject 3 :->");
m3=Integer.parseInt(s1.readLine());
System.out.print("Subject 4 :->");
m4=Integer.parseInt(s1.readLine());
System.out.print("Subject 5 :->");
m5=Integer.parseInt(s1.readLine());
System.out.print("Subject 6 :->");
m6=Integer.parseInt(s1.readLine());
sum = m1 + m2 + m3 + m4 + m5 + m6;
System.out.println("Sum = "+sum);
per = sum / 6;
System.out.println("\nPercentage = "+per);
if (per>=70)
{
System.out.println("\nDistinction Class");
}
else if (per>=60&&per<=69)
{
System.out.println("\nFirst Class");
}
else if (per>=50&&per<=59)
{
System.out.println("\nSecond Class");
}
else if (per>=40&&per<=49)
{
System.out.println("\nThird Class");
}
else if (per<=40)
{
System.out.println("\nFail");
}
}
catch (Exception e)
{
System.out.print("in velid" +e);
}
}
}
0 comments:
Post a Comment