I don’t know how to add reset game with yes or no input user I’ve tried many solutions and it doesn’t work.
here is my code:
import java.util.Scanner; public class Pr16 { public static void main(String[] args) { Scanner in = new Scanner(System.in); String a = "Stone"; String b = "Scissors"; String c = "Paper"; //a > b //b > c //c > a System.out.println("Player one choose:"); String x = in.nextLine(); System.out.println("Player two choose:"); String y = in.nextLine(); String answer = ""; do { if ((x.equalsIgnoreCase(a) && (y.equalsIgnoreCase(b)))) { System.out.println("Player one won"); } else if ((x.equalsIgnoreCase(b) && (y.equalsIgnoreCase(c)))) { System.out.println("Player one won"); } else if ((x.equalsIgnoreCase(c) && (y.equalsIgnoreCase(a)))) { System.out.println("Player one won"); } else { System.out.println("Player two won"); } System.out.println("Do you want to play again? YES / NO"); answer= in.nextLine(); } while (answer.equalsIgnoreCase("YES")); if (answer.equalsIgnoreCase("NO")){ System.out.println("Goodbye!"); } } }
any way to add game reset to my code above? any advice would be appreciated.