[Java] Need Help 02-23-2013, 09:49 PM
#1
Hello HC!
Today I have an assignment that I am doing for java, but I need some help. Here is the assignment:
Write a program that asks a user for input. If the user presses enter, the input is echoed back to the command line. The computer asks again for input (and echoes it back) until the user enters "exit" or "quit".
An example output might look like this:
I have researched about this...I know that I need to use the scanner utility and use the scanner to set the variable that the user types in and then use a loop to make it keep repeating an if statement or something until it reads the exit. My problem is I don't know what loop to use or anything. I looked up the while, do while, and for loop, but didn't find a way to apply it. I do not want the code just handed to me, I just want to know what to use in order to make this work. Any help would be appreciated. Thank you very much for your time.
Today I have an assignment that I am doing for java, but I need some help. Here is the assignment:
Write a program that asks a user for input. If the user presses enter, the input is echoed back to the command line. The computer asks again for input (and echoes it back) until the user enters "exit" or "quit".
An example output might look like this:
Quote:your input?
aaa
aaa
your input?
Hello
Hello
your input?
exit
I have researched about this...I know that I need to use the scanner utility and use the scanner to set the variable that the user types in and then use a loop to make it keep repeating an if statement or something until it reads the exit. My problem is I don't know what loop to use or anything. I looked up the while, do while, and for loop, but didn't find a way to apply it. I do not want the code just handed to me, I just want to know what to use in order to make this work. Any help would be appreciated. Thank you very much for your time.