-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRankers.java
More file actions
48 lines (47 loc) · 1006 Bytes
/
Rankers.java
File metadata and controls
48 lines (47 loc) · 1006 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
import java.util.Scanner;
class Records{
String[] name=new String[100];
int[] rank=new int[100];
int n;
Records(int num){
n=num;
}
void readValues(Scanner sc){
for(int i=0;i<n;i++){
System.out.println("enter record details");
name[i]=sc.next();
rank[i]=sc.nextInt();
}
System.out.println("end of input");
}
void display(){
System.out.println("Vomiting all records");
for(int i=0;i<n;i++){
System.out.println("name: "+name[i]+" rank: "+rank[i]);
}
}
}
class Rank extends Records{
int highest;
Rank(int n){ super(n); }
void highest_rank(){
int min=rank[0];
for(int i=1;i<n;i++){
if(min>rank[i]) min=i;
}
highest=min;
}
public String toString(){
return name[highest]+" has topped with AIR "+rank[highest] ;
}
}
public class Rankers{
public static void main(String args[]){
Rank r1=new Rank(5);
Scanner sc=new Scanner(System.in);
r1.readValues(sc);
r1.highest_rank();
System.out.println("Who has topped this time?\n"+r1);
r1.display();
}
}