Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Return Top 5

 
Abdulmajeed Alroumi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



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
Pie
Posts: 5415
52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you show us how you want it printed out.
 
Abdulmajeed Alroumi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic