Advertisement
Guest User

easter egg - Doycho

a guest
Apr 10th, 2020
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class EasterEggsBattle {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         int eggs1 = Integer.parseInt(scan.nextLine());
  7.         int eggs2 = Integer.parseInt(scan.nextLine());
  8.         String imput = scan.nextLine();
  9.         while (!imput.equals("End of battle")) {
  10.             if (imput.equals("one")) {
  11.                
  12.                 eggs2--;
  13.             } else {
  14.                 eggs1--;
  15.              
  16.             }
  17.             if (eggs1 == 0 || eggs2 == 0) {
  18.                 break;
  19.             }
  20.             imput= scan.nextLine();
  21.         }
  22.         if (eggs1 == 0) {
  23.             System.out.printf("Player one is out of eggs. Player two has %d eggs left.", eggs2);
  24.         } else if (eggs2 == 0) {
  25.             System.out.printf("Player two is out of eggs. Player one has %d eggs left.", eggs1);
  26.         } else {
  27.             System.out.printf("Player one has %d eggs left.%n", eggs1);
  28.             System.out.printf("Player two has %d eggs left.", eggs2);
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement