Results 1 to 6 of 6
  1. #1
    Implode is offline Member
    Join Date
    Aug 2009
    Posts
    50
    Rep Power
    0

    Question Basic high score program

    I would like to know the best way write a program that prompts the user to enter the students names and grades. then it outputs the students name and the highest grade.

    I know the Math.max() only takes 2 args, is there not an easier way for an unknown amount of variables.

    Please help with this program.

    thanks

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default

    It depends how you store the input in your program. Have a look at Arrays.sort(); Collections.sort(); Comparator and Comparable

  3. #3
    Implode is offline Member
    Join Date
    Aug 2009
    Posts
    50
    Rep Power
    0

    Default

    Thanks alot for the quick response.

  4. #4
    steelshark is offline Member
    Join Date
    Aug 2009
    Posts
    25
    Rep Power
    0

    Default

    An array should do the trick for you as phHein pointed out.
    An hashset is perhaps even better because then you'll have a reference to the names aswel.

  5. #5
    Implode is offline Member
    Join Date
    Aug 2009
    Posts
    50
    Rep Power
    0

    Default

    havent got that far yet, actually the exercise which I had the question for wasnt even using arrays yet, it wasnt storing data, but, yeah I dont get why there some examples in books, and then as you learn more those older techniques become obsolete?

    Also , in the book I am using in my first year at university is the Daniel Liang, introduction to java comprehensive 7/E. and in the beginning there are examples to print out tables and triangles etc. is that even necessary, I thought there were more advanced software to do much better graphics.There are loops, nested for loops etc, to print out tables next to each other, the only reason I can think is that it is to teach us how to use loops properly, because surely it cant be so timewasting to write out loads of loops for printing in certain styles?

  6. #6
    senorbum is offline Member
    Join Date
    Aug 2009
    Posts
    76
    Rep Power
    0

    Default

    Most books do something like what you mentioned. Its a good way to visualize how loops and simple data structures are working.

Similar Threads

  1. show a high score from tetris
    By stessie in forum Java Applets
    Replies: 0
    Last Post: 03-19-2008, 04:00 AM
  2. Basic Program Please Help!!
    By VinceGuad in forum New To Java
    Replies: 3
    Last Post: 02-01-2008, 04:35 PM
  3. Replies: 2
    Last Post: 01-07-2008, 08:45 PM
  4. get the average and maximum score
    By Eric in forum Advanced Java
    Replies: 2
    Last Post: 07-01-2007, 05:15 AM
  5. Klaverjas Score 0.2
    By levent in forum Java Software
    Replies: 0
    Last Post: 05-23-2007, 08:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •