Advertisement
Spocoman

Cake Tycoon

Sep 2nd, 2024
270
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 plannedCakes = Integer.parseInt(scanner.nextLine());
  7.         double cakeFlour = Double.parseDouble(scanner.nextLine());
  8.         int flourAvailable = Integer.parseInt(scanner.nextLine()),
  9.                 truffleCount = Integer.parseInt(scanner.nextLine()),
  10.                 trufflePrice = Integer.parseInt(scanner.nextLine());
  11.  
  12.         int cakes = (int) (flourAvailable / cakeFlour);
  13.  
  14.         if (cakes >= plannedCakes) {
  15.             double cakePrice = (double) truffleCount * trufflePrice / plannedCakes * 1.25;
  16.             System.out.printf("All products available, price of a cake: %.2f", cakePrice);
  17.         } else {
  18.             double flourNeeded = plannedCakes * cakeFlour - flourAvailable;
  19.             System.out.printf("Can make only %d cakes, need %.2f kg more flour", cakes, flourNeeded);
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement