Didart

The Biscuit Factory

Nov 17th, 2021
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.25 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TheBiscuitFactory {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int biscuitsPerDay = Integer.parseInt(scanner.nextLine());
  8.         int workersCount = Integer.parseInt(scanner.nextLine());
  9.         int biscuitsFor30Days = Integer.parseInt(scanner.nextLine());
  10.  
  11.         double sumBiscuits = 0.0;
  12.  
  13.         for (int i = 1; i <= 30; i++) {
  14.  
  15.             if (i % 3 == 0) {
  16.                 sumBiscuits += Math.floor(0.75 * biscuitsPerDay *workersCount);
  17.             } else {
  18.                 sumBiscuits += (workersCount * biscuitsPerDay);
  19.             }
  20.         }
  21.         System.out.printf("You have produced %.0f biscuits for the past month.%n", sumBiscuits);
  22.  
  23.         double percent = 0.0;
  24.         if (sumBiscuits >= biscuitsFor30Days) {
  25.             percent = ((sumBiscuits - biscuitsFor30Days) / biscuitsFor30Days) * 100;
  26.             System.out.printf
  27.                     ("You produce %.2f percent more biscuits.", percent);
  28.         } else {
  29.             percent = ((biscuitsFor30Days - sumBiscuits) / biscuitsFor30Days) * 100;
  30.             System.out.printf
  31.                     ("You produce %.2f percent less biscuits.", percent);
  32.         }
  33.     }
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment