-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest21.java
60 lines (56 loc) · 1.28 KB
/
Test21.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
60
/*
import java.util.*;
class Student
{
private String name;
private double marks [];
public Student(String name ,double[] marks)
{
this.name=name;
this.marks=marks;
}
public String getname()
{
return (this.name);
}
public double findTotal()
{
double total=0.0;
for(double i :this.marks)
{
total=total+i;
}
return (total);
}
}
public class Test21
{
public static String getMax(Student[] student)
{
double maxMarks=0.0;
String maxStud="";
for(Student i:student)
{
double totalMarks=i.findTotal();
if(totalMarks>maxMarks)
{
maxStud=i.getname();
maxMarks=totalMarks;
}
}
return maxStud;
}
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
Student[] arr=new Student[3];
for(int i=0;i<3;i++)
{
String name=sc.next();
double[] m ={sc.nextDouble(),sc.nextDouble(),sc.nextDouble()};
arr[i]=new Student(name,m);
}
sc.close();
System.out.println(getMax(arr));
}
}*/