Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package OldExam10_01_2019_Part1;
- import java.util.Scanner;
- public class _01_SantasCookies {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- int singleCookie = 25;
- int cup = 140;
- int smallSpoon = 10;
- int bigSpoon = 20;
- int cookiesPerBox = 5;
- int minSize;
- int total = 0;
- for (int i = 0; i < n; i++) {
- int flour = Integer.parseInt(scanner.nextLine());
- int sugar = Integer.parseInt(scanner.nextLine());
- int cocoa = Integer.parseInt(scanner.nextLine());
- int flourCups = flour / cup;
- int sugarSpoons = sugar / bigSpoon;
- int cocoaSpoons = cocoa / smallSpoon;
- if (flourCups <= 0 || sugarSpoons <= 0 || cocoaSpoons <= 0) {
- System.out.println("Ingredients are not enough for a box of cookies.");
- }else {
- if (sugarSpoons < cocoaSpoons) {
- minSize = sugarSpoons;
- } else {
- minSize = cocoaSpoons;
- }
- int min = Math.min(minSize, flourCups);
- double totalCookiePerBake = Math.floor(cup + smallSpoon + bigSpoon)
- * min / singleCookie;
- int boxesPerBatch = (int) totalCookiePerBake / cookiesPerBox;
- total += boxesPerBatch;
- System.out.println("Boxes of cookies: " + boxesPerBatch);
- }
- }
- System.out.println("Total boxes: " + total);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement