import java.util.Scanner;
public class PlayAgain {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
boolean playing = true;
char replayCheck;
do { //start do-while
System.out.print("Play again? (y/n): ");
boolean validInput = false;
while (validInput = false){ //start while
replayCheck = input.next().charAt(0);
switch (replayCheck) { //start switch
case 'y':
case 'Y':
validInput = true;
playing = true;
break;
case 'n':
case 'N':
validInput = true;
playing = false;
break;
default:
System.out.println("Invalid input! please enter (y/n)");
validInput = false;
break;
} //end switch
} //end while
} while (playing = true); //end do-while
System.out.println("Thanks for playing!");
} //end main
} //end class
If the user enters n/N
the program plays again, same goes for any other input. The logic seems just fine, but I get "the assigned value is never used" on the line with replayCheck = input.next().charAt(0);
so I suspect the issue is there.
I'm a bit of a noobie. Any suggestions are welcome!