File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Return Top 5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Return Top 5 " Watch "Return Top 5 " New topic
Author

Return Top 5

Abdulmajeed Alroumi
Greenhorn

Joined: Jun 24, 2012
Posts: 6



Ok this is my code and I am trying to return the top five Grade but it gives me something like this:
Jack 10 6 15 10 41 32 66 Mary 5 80 42 90 56 78 31 Top five:76.4
76.4
Mike 55 89 92 77 21 0 89 Top five:84.6
84.6
Luke 8 10 31 26 94 65 74 Top five:61.6
61.6
Kyle 19 20 52 50 3 20 29 Joe 20 5 66 13 77 5 40 Top five:45.2
45.2
Vivi 77 100 31 93 90 0 72 Top five:92.6
92.6


it does print the answer but would love to separate them as to print the top five in whole new line and the list and grades in another line

Thanks in advance
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3578
    
  14

Hi there!

First of all, I'd like to recommend that you use clear variable names and use coding standard practices. Right now it's not very clear at all what your Grade array holds.

Also, break up your code in classes and methods. Right now you only have one main() method that does everything in your program. Consider:
Now you can simply add methods that perform operations on these data types.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4165
    
  21

Why don't you show us how you want it printed out.


Steve
Abdulmajeed Alroumi
Greenhorn

Joined: Jun 24, 2012
Posts: 6
Thanks Stephan for explanation

The output I want would be something like this:

we have the average and the grades

Jack 10 6 15 10 41 32 66

Mary 5 80 42 90 56 78 31 76.4

Mike 55 89 92 77 21 0 89 84.6

Luke 8 10 31 26 94 65 74 :61.6

Kyle 19 20 52 50 3 20 29

Joe 20 5 66 13 77 5 40 45.2

Vivi 77 100 31 93 90 0 72 92.6
_______________________________

//here I want another line separated that will return the top five Grades in another line
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Return Top 5
 
Similar Threads
100 times "hello world" without loop or recursive
shift
shift question
shift
doubt in majji