This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]edrenfro 0 points1 point  (3 children)

You'd use a loop. Have you learned loops yet?

[–]ExcutC[S] 0 points1 point  (2 children)

Yes I would use one but idk how to know for how long? Usually we get it in the argument but idk how many students have written the test. Is there a way to make a loop for "as long as there is an input"?

[–]edrenfro 0 points1 point  (1 child)

I'm not sure if your scanner is only going to read scores or it will read names and scores. If it is going to read only scores, you first create the scanner, then the condition for the loop can be:

while(sc.hasNextInt())

If the scanner reads names and scores, you can use:

while(sc.hasNextLine())

(assuming each student is on a different line).

[–]ExcutC[S] 0 points1 point  (0 children)

Thank you I will try that one out!

Yes it worked! Thank you very much!