import java.io.*;
class student
{
String name;
int rno;
Student(String n,int r)
{
name=n;
rno=r;
}
}
class mark extends Student
{
int m1,m2,m3;
mark(String n,int r,int e,int m)
{
super(n,r);
m1=t;
m2=e;
m3=m;
}
}
class result extends mark
{
double avg;
int tot;
String res,grade;
result(String n,int r,int e,int m)
{
super(n,r,t,e,m);
}
void calculate()
{
tot=m1+m2+m3;
avg=tot/3;
System.out.print("\t"+tot);
System.out.print("\t"+avg);
if((m1>=50)&&(m2>=50)&&(m3>=50))
{
res="PASS";
if(avg>=80&&avg<100)
grade="Destination";
else if((avg>=70)&&(avg<80))
grade="A";
else if((avg>=60)&&(avg<70))
grade="B";
else
grade="C";
}
else
{
res="FAIL";
grade="*********";
}
}
void display()
{
System.out.println("\n"+name+"\t"+rno+"\t"+m1+"\t"+m2+"\t"+m3+"\t"+tot+"\t"+avg+"\t"+res+"\t"+grade);
}
}
class mhstu
{
public static void main(String args[])throws IOException
{
String n;
int r1,t1,e1,m1,m;
System.out.println("\t\tStudent Details");
System.out.println("\t\t-------------");
DataInputStream x=new DataInputStream(System.in);
System.out.print("Enter the number of students:");
m=Integer.parseInt(x.readLine());
result obj[]=new result[20];
for(int i=1;i<=m;i++)
{
System.out.println("Student:"+i);
System.out.println("-------");
System.out.print("Enter the Student Name:");
n=x.readLine();
System.out.print("Enter the Rollno:");
r1=Integer.parseInt(x.readLine());
System.out.print("Enter the Mark1:");
t1=Integer.parseInt(x.readLine());
System.out.print("Enter the Mark2:");
e1=Integer.parseInt(x.readLine());
System.out.print("Enter the Mark3:");
m1=Integer.parseInt(x.readLine());
obj[i]=new result(n,r1,t1,e1,m1);
obj[i]=calculate();
}
System.out.println("----------------------------------------------------------");
System.out.println("NAME \t ROLLNO \t MARK1 \t MARK2 \t MARK3 \t TOTAL \t AVERAGE \t RESULT \t GRADE");
System.out.println("-----------------------------------------------------------");
for(int i=1;i<=m;i++)
{
obj[i].display();
System.out.println("\n");
}
}
}
--------------
OUTPUT:
-------------
Student Details
-------------------
Enter the number of students
5
Student:1
-----------
Enter the Name
Ashok
Enter the Rollno
11
Enter the Mark1
98
Enter the Mark2
80
Enter the Mark3
95
Student:2
-----------
Enter the Name
Arun
Enter the Rollno
12
Enter the Mark1
89
Enter the Mark2
80
Enter the Mark3
78
Student:3
-----------
Enter the Name
Viji
Enter the Rollno
13
Enter the Mark1
78
Enter the Mark2
80
Enter the Mark3
70
Student:4
-----------
Enter the Name
Sakthi
Enter the Rollno
14
Enter the Mark1
45
Enter the Mark2
50
Enter the Mark3
56
Student:5
-----------
Enter the Name
Selvi
Enter the Rollno
15
Enter the Mark1
35
Enter the Mark2
34
Enter the Mark3
35
----------------------------------------------------------------------------------------------
Name Rollno Mark1 Mark2 Mark3 Total Average Result Grade
----------------------------------------------------------------------------------------------
Ashok 11 98 80 95 273 91.0 PASS Destination
Arun 12 89 80 78 247 82.0 PASS A
Viji 13 78 80 70 228 76.0 PASS B
Sakthi 14 45 50 56 151 50.0 PASS C
Selvi 15 35 34 35 104 34.0 FAIL ***
class student
{
String name;
int rno;
Student(String n,int r)
{
name=n;
rno=r;
}
}
class mark extends Student
{
int m1,m2,m3;
mark(String n,int r,int e,int m)
{
super(n,r);
m1=t;
m2=e;
m3=m;
}
}
class result extends mark
{
double avg;
int tot;
String res,grade;
result(String n,int r,int e,int m)
{
super(n,r,t,e,m);
}
void calculate()
{
tot=m1+m2+m3;
avg=tot/3;
System.out.print("\t"+tot);
System.out.print("\t"+avg);
if((m1>=50)&&(m2>=50)&&(m3>=50))
{
res="PASS";
if(avg>=80&&avg<100)
grade="Destination";
else if((avg>=70)&&(avg<80))
grade="A";
else if((avg>=60)&&(avg<70))
grade="B";
else
grade="C";
}
else
{
res="FAIL";
grade="*********";
}
}
void display()
{
System.out.println("\n"+name+"\t"+rno+"\t"+m1+"\t"+m2+"\t"+m3+"\t"+tot+"\t"+avg+"\t"+res+"\t"+grade);
}
}
class mhstu
{
public static void main(String args[])throws IOException
{
String n;
int r1,t1,e1,m1,m;
System.out.println("\t\tStudent Details");
System.out.println("\t\t-------------");
DataInputStream x=new DataInputStream(System.in);
System.out.print("Enter the number of students:");
m=Integer.parseInt(x.readLine());
result obj[]=new result[20];
for(int i=1;i<=m;i++)
{
System.out.println("Student:"+i);
System.out.println("-------");
System.out.print("Enter the Student Name:");
n=x.readLine();
System.out.print("Enter the Rollno:");
r1=Integer.parseInt(x.readLine());
System.out.print("Enter the Mark1:");
t1=Integer.parseInt(x.readLine());
System.out.print("Enter the Mark2:");
e1=Integer.parseInt(x.readLine());
System.out.print("Enter the Mark3:");
m1=Integer.parseInt(x.readLine());
obj[i]=new result(n,r1,t1,e1,m1);
obj[i]=calculate();
}
System.out.println("----------------------------------------------------------");
System.out.println("NAME \t ROLLNO \t MARK1 \t MARK2 \t MARK3 \t TOTAL \t AVERAGE \t RESULT \t GRADE");
System.out.println("-----------------------------------------------------------");
for(int i=1;i<=m;i++)
{
obj[i].display();
System.out.println("\n");
}
}
}
--------------
OUTPUT:
-------------
Student Details
-------------------
Enter the number of students
5
Student:1
-----------
Enter the Name
Ashok
Enter the Rollno
11
Enter the Mark1
98
Enter the Mark2
80
Enter the Mark3
95
Student:2
-----------
Enter the Name
Arun
Enter the Rollno
12
Enter the Mark1
89
Enter the Mark2
80
Enter the Mark3
78
Student:3
-----------
Enter the Name
Viji
Enter the Rollno
13
Enter the Mark1
78
Enter the Mark2
80
Enter the Mark3
70
Student:4
-----------
Enter the Name
Sakthi
Enter the Rollno
14
Enter the Mark1
45
Enter the Mark2
50
Enter the Mark3
56
Student:5
-----------
Enter the Name
Selvi
Enter the Rollno
15
Enter the Mark1
35
Enter the Mark2
34
Enter the Mark3
35
----------------------------------------------------------------------------------------------
Name Rollno Mark1 Mark2 Mark3 Total Average Result Grade
----------------------------------------------------------------------------------------------
Ashok 11 98 80 95 273 91.0 PASS Destination
Arun 12 89 80 78 247 82.0 PASS A
Viji 13 78 80 70 228 76.0 PASS B
Sakthi 14 45 50 56 151 50.0 PASS C
Selvi 15 35 34 35 104 34.0 FAIL ***
0 comments:
Post a Comment