A_Marinov

Problem_04

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