forked from rakhi2207/java-programs-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Student.java
59 lines (50 loc) · 1.37 KB
/
Student.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
class Student
{
private int hindi, english, maths;
private String name;
double avg;
public Student(int h,int e,int m,String n)
{
hindi=h;
english=e;
maths=m;
name=n;
}
public void display()
{
System.out.println("Marks in Hindi "+hindi);
System.out.println("Marks in English "+english);
System.out.println("Marks in Maths "+maths);
System.out.println("Name of Student is "+name);
}
public double average()
{
avg=(hindi+english+maths);
return(avg/3);
}
public static void main(String[] args)
{
Student Jiya=new Student(80,90,95,"Jiya");
double jiyaavg=Jiya.average();
Student Rakhi=new Student(80,85,90,"Rakhi");
double rakhiavg=Rakhi.average();
Student pratyush=new Student(100,95,95,"pratyush");
double praavg=pratyush.average();
Student swati=new Student(81,89,90,"swati");
double swatiavg=swati.average();
Student saksham=new Student(81,91,85,"saksham");
double sakavg=saksham.average();
double[] m={jiyaavg,rakhiavg,praavg,swatiavg,sakavg};
double highmarks=m[0];
int highmarksindex=0;
for(int i=0;i<m.length;i++)
{
if(m[i]>highmarks)
{
highmarks=m[i];
highmarksindex=i;
}
}
System.out.println("RollNo of Topper Student is " + (highmarksindex+1) + " and average the marks of the Student is " + highmarks );
}
}