Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class BeehiveDefense_05 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int countBees = Integer.parseInt(scanner.nextLine());
- int health = Integer.parseInt(scanner.nextLine());
- int attack = Integer.parseInt(scanner.nextLine());
- while (countBees >= 100) {
- countBees -= attack;
- health -= countBees * 5;
- if (health <= 0) {
- System.out.printf("Beehive won! Bees left %d.", countBees);
- break;
- }
- }
- if (health > 0) {
- if (countBees < 0) {
- countBees = 0;
- }
- System.out.printf("The bear stole the honey! Bees left %d.", countBees);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement