Roadstar3

Fundamentals Mid-Exams Biscuits Factory

Feb 26th, 2020
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.53 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class BiscuitsFactory {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.         int amountOfBiscuits = Integer.parseInt(scanner.nextLine());
  8.         int workersCount = Integer.parseInt(scanner.nextLine());
  9.         int otherProduce = Integer.parseInt(scanner.nextLine());
  10.         int countDays = 1;
  11.         int days = 30;
  12.         int sum = 0;
  13.  
  14.         int countBiscuitsForDay = amountOfBiscuits * workersCount;
  15.         sum = ImplementationMethod(countDays, days, sum, countBiscuitsForDay);
  16.         System.out.printf("You have produced %d biscuits for the past month.%n", sum);
  17.  
  18.         if (sum >= otherProduce) {
  19.             int diff = sum - otherProduce;
  20.             double percentage = (diff * 1.00 / otherProduce) * 100;
  21.             System.out.printf("You produce %.2f percent more biscuits.",percentage);
  22.         }else {
  23.             int diff = otherProduce - sum;
  24.             double percentage = (diff * 1.00 / otherProduce) * 100;
  25.             System.out.printf("You produce %.2f percent less biscuits.",percentage);
  26.         }
  27.     }
  28.  
  29.     private static int ImplementationMethod(int countDays, int days, int sum, int countBiscuitsForDay) {
  30.         for (int i = 1; i <= days; i++) {
  31.             if (countDays == 3) {
  32.                 sum += countBiscuitsForDay * 0.75;
  33.                 countDays = 1;
  34.                 continue;
  35.             }
  36.             countDays++;
  37.             sum += countBiscuitsForDay;
  38.         }
  39.         return sum;
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment