Advertisement
meteor4o

JF-MidExam-02March-01.CookingMasterclass

Jun 29th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1.  
  2. 1
  3. import java.util.Scanner;
  4. 2
  5. 3
  6. class Main {
  7. 4
  8.   public static void main(String[] args) {
  9. 5
  10. 6
  11.   Scanner scanner = new Scanner(System.in);
  12. 7
  13. 8
  14.   double budget = Double.parseDouble(scanner.nextLine());
  15. 9
  16.   int students = Integer.parseInt(scanner.nextLine());
  17. 10
  18.   double priceFlourPkt = Double.parseDouble(scanner.nextLine());
  19. 11
  20.   double priceEgg = Double.parseDouble(scanner.nextLine());
  21. 12
  22.   double apron = Double.parseDouble(scanner.nextLine());
  23. 13
  24.  
  25. 14
  26.  
  27. 15
  28.   double priceTotal = (apron * Math.ceil(students * 1.2)) + priceEgg * students * 10 + (priceFlourPkt * (students - (students / 5)));
  29. 16
  30.   double aprons = apron * Math.ceil(students * 1.2);
  31. 17
  32.   double eggs = priceEgg * students * 10;
  33. 18
  34.   double flour = priceFlourPkt * (students - (students / 5));
  35. 19
  36. 20
  37.   //
  38. 21
  39.   if  (priceTotal <= budget) {
  40. 22
  41.     System.out.printf("Items purchased for %.2f$.", priceTotal);
  42. 23
  43.   } else {
  44. 24
  45.     double diff = priceTotal - budget;
  46. 25
  47.     System.out.printf("%.2f$ more needed.", diff);
  48. 26
  49.   }
  50. 27
  51.   }
  52. 28
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement