SHARE
TWEET

Untitled

a guest Sep 21st, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         // Your code goes below this line.
  2.         Scanner myScanner = new Scanner(System.in);
  3.  
  4.         int aantalLucifers = 21;
  5.         int hoeveelMoetWeg;
  6.         while (aantalLucifers != 1) {
  7.  
  8.             //PLAYER ONE
  9.             if (aantalLucifers == 1){
  10.                 System.out.println("Player one has won!");
  11.             } else {
  12.                 System.out.print("Player one, select a number of matches: ");
  13.                 hoeveelMoetWeg = myScanner.nextInt();
  14.                 if (hoeveelMoetWeg >= 1 && hoeveelMoetWeg <= 3) {
  15.                     aantalLucifers -= hoeveelMoetWeg;
  16.                     System.out.println("There are " + aantalLucifers + " matches left.");
  17.                 } else {
  18.                     System.out.println("Please enter a number between 1 and 3.");
  19.                     System.out.print("Player one, select a number of matches: ");
  20.                     hoeveelMoetWeg = myScanner.nextInt();
  21.                     aantalLucifers -= hoeveelMoetWeg;
  22.                     System.out.println("There are " + aantalLucifers + " matches left.");
  23.                 }
  24.             }
  25.             //PLAYER TWO
  26.             if (aantalLucifers == 1) {
  27.                 System.out.println("Player two has won!");
  28.             } else {
  29.                 System.out.print("Player two, select a number of matches: ");
  30.                 hoeveelMoetWeg = myScanner.nextInt();
  31.                 if (hoeveelMoetWeg >= 1 && hoeveelMoetWeg <= 3) {
  32.                     aantalLucifers -= hoeveelMoetWeg;
  33.                     System.out.println("There are " + aantalLucifers + " matches left.");
  34.                 } else {
  35.                     System.out.println("Please enter a number between 1 and 3.");
  36.                     System.out.print("Player two, select a number of matches: ");
  37.                     hoeveelMoetWeg = myScanner.nextInt();
  38.                     aantalLucifers -= hoeveelMoetWeg;
  39.                     System.out.println("There are " + aantalLucifers + " matches left.");
  40.                 }
  41.             }
  42.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top