0

Hi, My name is Micky.

I have requirement, but i don't know how to start it, could anyone help me out. here is the requirement.

In a class there are 10 Students with name , marks , Percentage and there rank should be in the below format

Name Marks Percentage Rank

bbb 100 100 1
ccc 100 100 1
ddd 99 99 4
eee 99 99 4
fff 98 98 6
ggg 98 98 6
hhh 97 97 8
iii 96 95 9
jjj 96 96 10

4
Contributors
3
Replies
23
Views
3 Years
Discussion Span
Last Post by JamesCherrill
0

So you want to read that data into memory -- into something like a List or array. And then you want to sort it -- based on "Marks" and "Percentage" it seems. (Presumably, the input would not already be in sorted order.)

Now, depending on how you do the sort, the "top 10" could be the first or last 10. If you're "smart" about it, the "top 10" would be the first ten. So you just "display" (print) the first ten.

1

Start by defining a Student class that has instance variables for name. marks etc.
Input the raw data, create the instances of Student and add them to a List like JeffGrigg said.

Java has methods to sort a List:
http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#sort%28java.util.List,%20java.util.Comparator%29

you need to create one or more Comparators ( http://docs.oracle.com/javase/7/docs/api/java/util/Comparator.html ) that define the order in which you want things sorted.

Votes + Comments
Yep; more good advice.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.