-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentComparison.java
More file actions
42 lines (41 loc) · 924 Bytes
/
StudentComparison.java
File metadata and controls
42 lines (41 loc) · 924 Bytes
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
import java.util.*;;
public class StudentComparison {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
ArrayList<Student> students=new ArrayList<Student>();
while(!sc.hasNext()){
String s=sc.nextLine();
String[] str=s.split(" ");
int len=str.length-1;
int[] marks=new int[len];
for(int i=1;i<=len;i++)
{
marks[i]=Integer.parseInt(str[i]);
}
Student st=new Student(str[0], marks);
students.add(st);
}
}
public static String find_max( ArrayList<Student> S )
{
int[] a = new int[S.size()];
for(int i=0;i<S.size();i++)
{
for(int j=i+1;j<S.size();j++)
{
a[i]=a[i]+S.get(i).compareTo(S.get(j));
}
}
String max_1 = "";
int k= 0;
for(int i=1;i<S.size();i++)
{
if(k>a[i])
{
k=i;
}
}
max_1 = max_1+S.get(k).name;
return max_1;
}
}