Anyway, Ive been learning doing while loops and user input using scanner, but combing them is something I cannot seem to solve. (If you can refer to me a video/website that deals with the same type of solution, i would be really happy!!)
Here is what needs to be done. read a integer from the keyboard over and over until is read 0< number (using WHILE loop)
Here is what ive done:
Alright but if i want to now use a text and number, and I want to print the text much as the number specifies, how do I do that? using While
Carey Brown wrote:You'll want to replace your a-- with edd.nextInt(). Every time through the loop you'll want to get another int.
Also, variable names should begin with a lower case character, so it should be edd and not Edd.
Thanks for your help! Hope you dont mind these noob questions.
This will not give you what you expect because nextInt() leaves a new-line character in the input buffer and nextLine() will see that and return an empty string. After nextInt() you have to flush the new-line by calling nextLine().
Elias Gomersen wrote:Here is what needs to be done. read a integer from the keyboard over and over until is read 0< number (using WHILE loop)
On second reading I find this a poorly phrased requirement that is subject to misinterpretation. "0< number", what number? I assume that the keyboard will be read over and over because the read will be inside the body of the loop.
This needs some clarification.