Advertisement
desislava_topuzakova

05. Beehive Defense

Jun 10th, 2020
1,142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class BeehiveDefense_05 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int countBees = Integer.parseInt(scanner.nextLine());
  7.         int health = Integer.parseInt(scanner.nextLine());
  8.         int attack = Integer.parseInt(scanner.nextLine());
  9.  
  10.         while (countBees >= 100) {
  11.             countBees -= attack;
  12.             health -= countBees * 5;
  13.             if (health <= 0) {
  14.                 System.out.printf("Beehive won! Bees left %d.", countBees);
  15.                 break;
  16.             }
  17.         }
  18.         if (health > 0) {
  19.             if (countBees < 0) {
  20.                 countBees = 0;
  21.             }
  22.             System.out.printf("The bear stole the honey! Bees left %d.", countBees);
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement