Advertisement
Spocoman

Easter Bake

Sep 4th, 2024
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int quantity = Integer.parseInt(scanner.nextLine()),
  7.                 sugar, flour, maxSugar = 0, maxFlour = 0;
  8.         double totalSugar = 0, totalFlour = 0;
  9.  
  10.         for (int i = 0; i < quantity; i++) {
  11.             sugar = Integer.parseInt(scanner.nextLine());
  12.             flour = Integer.parseInt(scanner.nextLine());
  13.  
  14.             if (maxSugar < sugar) {
  15.                 maxSugar = sugar;
  16.             }
  17.             if (maxFlour < flour) {
  18.                 maxFlour = flour;
  19.             }
  20.  
  21.             totalSugar += sugar;
  22.             totalFlour += flour;
  23.         }
  24.  
  25.         System.out.println("Sugar: " + (int) Math.ceil(totalSugar / 950) + "\nFlour: " + (int) Math.ceil(totalFlour / 750)
  26.                 + "\nMax used flour is " + maxFlour + " grams, max used sugar is " + maxSugar + " grams.\n"
  27.         );
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement