grach

BeePopulation - exam 02May2020

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