Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class BeehivePopulation {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int population = Integer.parseInt(scanner.nextLine());
- int years = Integer.parseInt(scanner.nextLine());
- int migration = 0;
- int beesBorn = 0;
- int beesDead = 0;
- for (int i = 1; i <= years; i++) {
- beesBorn = population / 10 * 2;
- population = beesBorn + population;
- if (i % 5 == 0) {
- migration = population / 50 * 5;
- population = population - migration;
- }
- beesDead = population / 20 * 2;
- population = population - beesDead;
- }
- System.out.printf("Beehive population: %d", population);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement