Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int plannedCakes = Integer.parseInt(scanner.nextLine());
- double cakeFlour = Double.parseDouble(scanner.nextLine());
- int flourAvailable = Integer.parseInt(scanner.nextLine()),
- truffleCount = Integer.parseInt(scanner.nextLine()),
- trufflePrice = Integer.parseInt(scanner.nextLine());
- int cakes = (int) (flourAvailable / cakeFlour);
- if (cakes >= plannedCakes) {
- double cakePrice = (double) truffleCount * trufflePrice / plannedCakes * 1.25;
- System.out.printf("All products available, price of a cake: %.2f", cakePrice);
- } else {
- double flourNeeded = plannedCakes * cakeFlour - flourAvailable;
- System.out.printf("Can make only %d cakes, need %.2f kg more flour", cakes, flourNeeded);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement