Project Program Question 4
Project Program Question 4
A super class record has been defined to store the names and ranks of 50 students.
Define a
subclass Rank to find the highest rank along with the name.
Members functions
Member functions/methods:
void highest():find the index/location of the topmost rank and store it in index without
void display (): display the names and ranks along with the name having the topmost
rank.
ALGORITHM:-
class record
Step 1: start
Step 2: a single dimension array name and rank of size 50 are initialised
Record ()
Step 1: start
Step 4: end
void readValues ()
Step 1: start
Step 2: accept the name and rank of the students from the user
Step 3: end
void display ()
Step 1: start
Step 2: print the name of the students and ranks with suitable headings
Step 3: end
class ended
Step 1: start
Rank ()
Step 1: start
Step 3: end
void highest ()
Step 1: start
Step 2: find the index of the topmost rank and store it in index without sorting
Step 3: end
void display ()
Step 1: start
Step 2: print the names and ranks of the students with the name having the topmost
rank
Step 3:
end
import java.util.*;
class Record
Record()
for(int i=0;i<50;i++)
name[i]="";
rnk[i]=0;
void readValues()
for(int i=0;i<50;i++)
name[i]=sc.next();
rnk[i]=sc.nextInt();
void display()
System.out.println("NAME\t\t"+"RANK");
for(int i=0;i<50;i++)
System.out.println(name[i]+"\t\t"+rnk[i]);
int index;
Rank()
index=0;
void highest()
for(int i=0;i<50;i++)
if(rnk[i]<rnk[index])
index=i;
void display()
super.display();
}
OUTPUT:-
ENTER NAME OF THE STUDENT:
SUMAN
11
AMAN
ASHOK
NITIN
MOHIT
NAME
SUMAN
AMAN
ASHOK
NITIN
MOHIT
RANK
11
4
7
2
9
THE TOPMOST RANK: 2