Advertisement
damesova

Santa's Cookies [Mimi]

Mar 6th, 2019
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.63 KB | None | 0 0
  1. package OldExam10_01_2019_Part1;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class _01_SantasCookies {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         int n = Integer.parseInt(scanner.nextLine());
  9.  
  10.         int singleCookie = 25;
  11.         int cup = 140;
  12.         int smallSpoon = 10;
  13.         int bigSpoon = 20;
  14.         int cookiesPerBox = 5;
  15.  
  16.         int minSize;
  17.         int total = 0;
  18.  
  19.         for (int i = 0; i < n; i++) {
  20.             int flour = Integer.parseInt(scanner.nextLine());
  21.             int sugar = Integer.parseInt(scanner.nextLine());
  22.             int cocoa = Integer.parseInt(scanner.nextLine());
  23.             int flourCups = flour / cup;
  24.             int sugarSpoons = sugar / bigSpoon;
  25.             int cocoaSpoons = cocoa / smallSpoon;
  26.  
  27.             if (flourCups <= 0 || sugarSpoons <= 0 || cocoaSpoons <= 0) {
  28.                 System.out.println("Ingredients are not enough for a box of cookies.");
  29.             }else {
  30.                 if (sugarSpoons < cocoaSpoons) {
  31.                     minSize = sugarSpoons;
  32.                 } else {
  33.                     minSize = cocoaSpoons;
  34.                 }
  35.                 int min = Math.min(minSize, flourCups);
  36.  
  37.                 double totalCookiePerBake = Math.floor(cup + smallSpoon + bigSpoon)
  38.                         * min / singleCookie;
  39.                 int boxesPerBatch = (int) totalCookiePerBake / cookiesPerBox;
  40.  
  41.                 total += boxesPerBatch;
  42.  
  43.                 System.out.println("Boxes of cookies: " + boxesPerBatch);
  44.             }
  45.         }
  46.  
  47.         System.out.println("Total boxes: " + total);
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement