Advertisement
CamiloCastilla

Untitled

Dec 11th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.10 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         int pileA = 3;
  9.         int pileB = 3;
  10.         int pileC = 3;
  11.         Scanner keyboard = new Scanner(System.in);
  12.         do {
  13.             System.out.println("\nA:  " + pileA + "  B:  " + pileB + "  C:  " + pileC);
  14.             System.out.print("\nChoose a pile: ");
  15.             String choice = keyboard.nextLine();
  16.             System.out.print("\nHow many to remove from pile " + choice + ": ");
  17.             int remove = keyboard.nextInt();
  18.             keyboard.nextLine();
  19.             if (choice.equals("A")) {
  20.                 pileA = pileA - remove;
  21.             } else if (choice.equals("B")) {
  22.                 pileB = pileB - remove;
  23.             } else if (choice.equals("C")) {
  24.                 pileC = pileC - remove;
  25.             }
  26.         }
  27.         while (pileA > 0 || pileB > 0 || pileC > 0);
  28.  
  29.             if ((pileA == 0) && (pileB == 0) && (pileC == 0)) {
  30.                 System.out.println("All piles are empty good job!");
  31.             }
  32.  
  33.  
  34.  
  35.         }
  36.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement