I am trying to build a simple program that will keep doing it until a certain conditional is met. In this case whether it is true or false. I've been playing around with it for a while, but I still can't get it to work as I want.
import java.util.Scanner;
public class oddeven {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter a number: ");
int num = scan.nextInt();
boolean play = true;
String restart = " ";
do {
if((num % 2) == 0) {
System.out.println("That number is even!");
} else {
System.out.println("That number is odd!");
}
System.out.println(
"Would you like to pick another number? (Type 'yes' or 'no')");
restart = scan.nextLine();
if(restart == "yes") {
System.out.println("Enter a number: ");
play = true;
} else {
System.out.println("Thanks for playing!");
play = false;
}
}
while(play == true);
}
}