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