-1

// I want this code to repeat after running. For example, after I ask "Do you want to play again?" If you enter 1 I want the code to run again.

import java.util.Scanner;

public class MadlibsRevised { public static void main (String[] args) {

    Scanner input = new Scanner(System.in);
    System.out.println("Want to play a game?? If yes, hit 1, if not enter -1 " );
    int gameStart = input.nextInt();
    int count = 0;
    while(gameStart == 1) {
        System.out.println("Enter an adjective");
        String Adj1 = input.nextLine();
        System.out.println("Enter another adjective");
        String Adj2 = input.nextLine();
        ....
        System.out.print("So get this, one day a man who is " + Adj1 ... ); 
        System.out.println("Wanna play again?? ");
    }

    while(gameStart == -1) {
        System.out.println("FINE I DIDN'T WANNA PLAY WITH YOU ANYWAYS!!");
        break;
    }



    }
}
Scary Wombat
  • 41,782
  • 5
  • 32
  • 62
JayPee
  • 3
  • 1
  • 3
  • Also, add `gameStart = input.nextInt();` to the bottom of your loop and also change the `while(gameStart == -1)` to `if (gameStart == -1) ` – Scary Wombat Oct 17 '18 at 01:19

1 Answers1

-1

Just add this after you print “Wanna play again??” (In the first while loop):

gameStart = input.nextInt();
mettleap
  • 1,324
  • 6
  • 16