I'm trying to get the users input to output on the next line to look something like this.
_ _ _ _ _ a
Note** They'll be picking their string length before this but I'm not too worried about that right now. Just want to figure out how to get their input to output.
Here is my code so far:
while (!userCorrect) {
Scanner input = new Scanner(System.in);
System.out.print("Guessing (round " + roundNumber + "): Choosing your letter from a-z: ");
String letter = input.nextLine();
for (int i=0; i<letter.length(); i++){ //this is where I'm getting lost
System.out.println("_" + letter.length());
}
if (letter.length () > 1) { //code will print an error if the user selects more than 1 character
System.out.println("You should not enter more than 1 character");
}
else {
System.out.println("end (round " + roundNumber + ")");
roundNumber++;
}
I created a for loop so it can print the lines and the character depending on their input. It's not working and it's giving the response like:
Please enter your desired string length: 5 Start guessing the string: Guessing (round 1): Choosing your letter from a-z: a _1 end (round 1) Guessing (round 2): Choosing your letter from a-z:
Any ideas or hints on how I can tweak this to make the output show?
Thanks in advance.