Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1
- import java.util.Scanner;
- 2
-
- 3
- class Main {
- 4
- public static void main(String[] args) {
- 5
-
- 6
- Scanner scanner = new Scanner(System.in);
- 7
-
- 8
- double budget = Double.parseDouble(scanner.nextLine());
- 9
- int students = Integer.parseInt(scanner.nextLine());
- 10
- double priceFlourPkt = Double.parseDouble(scanner.nextLine());
- 11
- double priceEgg = Double.parseDouble(scanner.nextLine());
- 12
- double apron = Double.parseDouble(scanner.nextLine());
- 13
- 14
- 15
- double priceTotal = (apron * Math.ceil(students * 1.2)) + priceEgg * students * 10 + (priceFlourPkt * (students - (students / 5)));
- 16
- double aprons = apron * Math.ceil(students * 1.2);
- 17
- double eggs = priceEgg * students * 10;
- 18
- double flour = priceFlourPkt * (students - (students / 5));
- 19
-
- 20
- //
- 21
- if (priceTotal <= budget) {
- 22
- System.out.printf("Items purchased for %.2f$.", priceTotal);
- 23
- } else {
- 24
- double diff = priceTotal - budget;
- 25
- System.out.printf("%.2f$ more needed.", diff);
- 26
- }
- 27
- }
- 28
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement