Monday, January 16, 2017

Program to display student report card.

import java.util.*;
class Student
{
int rollno,physics,chem,math;
String name,email;
public static void main(String...args)
{
Student s1=new Student();
Scanner sc=new Scanner(System.in);
System.out.print("Roll no. : ");
s1.rollno=sc.nextInt();
System.out.print("Name : ");
s1.name=sc.next();
System.out.print("Email : ");
s1.email=sc.next();
System.out.println("Enter the Marks following...");
System.out.print("Physics : ");
s1.physics=sc.nextInt();
System.out.print("Chemistry : ");
s1.chem=sc.nextInt();
System.out.print("Math : ");
s1.math=sc.nextInt();

int total=s1.physics+s1.chem+s1.math;

int avg=(total*100)/300;

String grade;
if(avg<33)
{
grade="Fail";
}
else if ( avg >=34 && avg <= 44 )
{
grade="III";
}
else if ( avg >= 45 && avg <= 59 )
{
grade="II";
}
else if ( avg >=60 && avg <= 74 )
{
grade="I";
}
else
{
grade="Distinction";
}

//Report card..
System.out.println("\n***Report Card***");
System.out.println("Roll no. : "+s1.rollno);
System.out.println("Name : "+s1.name);
System.out.println("Email : "+s1.email);
System.out.println("Physics : "+s1.physics);
System.out.println("Chemistry: "+s1.chem);
System.out.println("Math : "+s1.math);
System.out.println("Total : "+total);
System.out.println("Average : "+avg);
System.out.println("Grade : "+grade);


}
}

                                                                                                                               

Output:


1 comment: