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.
It depends how you store the input in your program. Have a look at Arrays.sort(); Collections.sort(); Comparator and Comparable
Thanks alot for the quick response.
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.
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?
Most books do something like what you mentioned. Its a good way to visualize how loops and simple data structures are working.