reset password
Author Message
jzunig20
Posts: 38
Posted 09:42 Apr 11, 2017 |

for this problem, i don't know why i can't input all the grades in one line like in the sample output. if i want all 10 scores to be stored in a variable, i have to press enter in order for them to be saved and actually give me the answer. There's no problem displaying the correct solution, where i'm stuck is reading all inputs in one line, or is it okay to press enter after every input which means they won't all be in the same line like in the sample output? the program still only asks once for the input.

can anyone give any hints on this 

kknaur
Posts: 540
Posted 09:49 Apr 11, 2017 |

You may have to enter each grade one at a time pressing enter after each key press.  The reason is that in your readGrade() method you are most likely making a new Scanner instance every time.  Each instance of Scanner has its own input buffer, so the first time you want to read all of the scores you might enter them on one line which means they are stored in the input buffer of the first Scanner.  After you call readGrade() again that input buffer is gone which means all of those scores are also gone.

This is intended.  You will need to enter each score one at a time pressing enter after every score.  During the lab this week, we will discuss a way to deal with Scanner in multiple methods.

jzunig20
Posts: 38
Posted 09:56 Apr 11, 2017 |

Thank you Keenan!