A_Marinov

Problem_05

Jun 7th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class BeehiveDefence {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int beesAmount = Integer.parseInt(scanner.nextLine());
  7.         int bearHealth = Integer.parseInt(scanner.nextLine());
  8.         int bearAttacks = Integer.parseInt(scanner.nextLine());
  9.  
  10.         int beeCount = beesAmount;
  11.  
  12.         boolean atacking = true;
  13.         while (atacking) {
  14.             if (beeCount < 100 && beeCount >= 0) {
  15.                 System.out.printf("The bear stole the honey! Bees left %d.", beeCount);
  16.                 atacking = false;
  17.                 break;
  18.             } else if (beeCount <= 100 && beeCount < 0) {
  19.                 System.out.println("The bear stole the honey! Bees left 0.");
  20.                 atacking = false;
  21.                 break;
  22.             } else if (bearHealth <= 0) {
  23.                 System.out.printf("Beehive won! Bees left %d.", beeCount);
  24.                 atacking = false;
  25.                 break;
  26.             } else {
  27.                 beeCount = beeCount - bearAttacks;
  28.                 bearHealth = bearHealth - (beeCount * 5);
  29.             }
  30.  
  31.         }
  32.  
  33.  
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment