- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.java
More file actions
Latest commit
50 lines (50 loc) · 972 Bytes
/
Copy pathMain.java
File metadata and controls
50 lines (50 loc) · 972 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
43
44
45
46
47
48
49
50
importjava.util.Scanner;
classStudent
{
publicStringname;
publicfloatpercentage;
Student(Stringname, floatpercentage)
{
this.name=name;
this.percentage=percentage;
}
}
classTestextendsStudent
{
Test(Stringname, floatpercentage)
{
super(name, percentage);
}
publicstaticvoiddisplay(Test[] obj)
{
for(inti=0;i<obj.length;i++)
{
for(intj=i+1;j<obj.length;j++)
{
if(obj[i].percentage<obj[j].percentage)
{
Testt = obj[i];
obj[i]=obj[j];
obj[j]=t;
}
}
}
System.out.println(obj[0].name + " " + obj[0].percentage);
}
}
classMain
{
publicstaticvoidmain(Stringargs[])
{
Scannersc = newScanner(System.in);
System.out.println("Enter number of students appeared in the test");
intsize = sc.nextInt();
Testobj[] = newTest[size];
for(inti=0;i<obj.length;i++)
{
System.out.println("Enter the details");
obj[i]=newTest(sc.next(), sc.nextFloat());
}
Test.display(obj);
}
}