Advertisement
desislava_topuzakova

04. Beehive Population

Jun 10th, 2020
1,006
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class BeehivePopulation_04 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int startPopulation = Integer.parseInt(scanner.nextLine());
  7.         int years = Integer.parseInt(scanner.nextLine());
  8.  
  9.         for (int year = 1; year <= years; year++) {
  10.             startPopulation += startPopulation / 10 * 2;
  11.             if (year % 5 == 0) {
  12.                 startPopulation -= startPopulation / 50 * 5;
  13.             }
  14.             startPopulation -= startPopulation / 20 * 2;
  15.         }
  16.  
  17.         System.out.printf("Beehive population: %d", startPopulation);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement