Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- int pileA = 3;
- int pileB = 3;
- int pileC = 3;
- Scanner keyboard = new Scanner(System.in);
- do {
- System.out.println("\nA: " + pileA + " B: " + pileB + " C: " + pileC);
- System.out.print("\nChoose a pile: ");
- String choice = keyboard.nextLine();
- System.out.print("\nHow many to remove from pile " + choice + ": ");
- int remove = keyboard.nextInt();
- keyboard.nextLine();
- if (choice.equals("A")) {
- pileA = pileA - remove;
- } else if (choice.equals("B")) {
- pileB = pileB - remove;
- } else if (choice.equals("C")) {
- pileC = pileC - remove;
- }
- }
- while (pileA > 0 || pileB > 0 || pileC > 0);
- if ((pileA == 0) && (pileB == 0) && (pileC == 0)) {
- System.out.println("All piles are empty good job!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement