Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class toyStore {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. double puzzle = 2.60;
  8. double talkingDoll = 3;
  9. double teddyBear = 4.10;
  10. double minion = 8.20;
  11. double truck = 2.00;
  12.  
  13. double priceOfVacation = Double.parseDouble(scanner.nextLine());
  14. double numberOfPuzzles = Double.parseDouble(scanner.nextLine());
  15. double numberOfTalkingDolls = Double.parseDouble(scanner.nextLine());
  16. double numberOfTeddyBears = Double.parseDouble(scanner.nextLine());
  17. double numberOfMinions = Double.parseDouble(scanner.nextLine());
  18. double numberOfTrucks = Double.parseDouble(scanner.nextLine());
  19.  
  20. double totalToysOrdered = numberOfMinions + numberOfPuzzles + numberOfTalkingDolls + numberOfTeddyBears + numberOfTrucks;
  21. double totalEarnings = (puzzle * numberOfPuzzles) + (talkingDoll * numberOfTalkingDolls) + (teddyBear * numberOfTeddyBears) + (minion * numberOfMinions) + (truck * numberOfTrucks);
  22.  
  23. if (totalToysOrdered >= 50) {
  24. double discount = totalEarnings * 0.25;
  25. double discountedPrice = totalEarnings - discount;
  26. double rentPrice = discountedPrice * 0.10;
  27. double revenue = discountedPrice - rentPrice;
  28. if (revenue >= priceOfVacation) {
  29. System.out.printf("Yes! %.2f lv left.", revenue - priceOfVacation);
  30. } else if (revenue < priceOfVacation) {
  31. double priceWhenFail = priceOfVacation - revenue;
  32. System.out.printf("Not enough money! %.2f lv needed.", priceWhenFail);
  33. }
  34.  
  35. } else if (totalToysOrdered < 50) {
  36. double rentPrice = totalEarnings * 0.10;
  37. double revenue = totalEarnings - rentPrice;
  38. if(revenue >= priceOfVacation){
  39. System.out.printf("Yes! %.2f lv left.", revenue - priceOfVacation);
  40. }else if(revenue < priceOfVacation){
  41. double priceWhenFail = priceOfVacation - revenue;
  42. System.out.printf("Not enough money! %.2f lv needed.", priceWhenFail);
  43.  
  44. }
  45.  
  46. }
  47.  
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement