Advertisement
Guest User

Untitled

a guest
May 24th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ToyShop {
  4. public static void main(String[] args) {
  5.  
  6.  
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9.  
  10. double vacationPrice = Double.parseDouble(scanner.nextLine());
  11. int puzzlesCount = Integer.parseInt(scanner.nextLine());
  12. int talkinDollsCount = Integer.parseInt(scanner.nextLine());
  13. int teddyBearsCount = Integer.parseInt(scanner.nextLine());
  14. int minionsCount = Integer.parseInt(scanner.nextLine());
  15. int trucksCount = Integer.parseInt(scanner.nextLine());
  16.  
  17. double puzzlesPrice = 2.60;
  18. double talkinDollsPrice = 3.00;
  19. double teddyBearsPrice = 4.10;
  20. double minionsPrice = 8.20;
  21. double trucksPrice = 2.00;
  22.  
  23. double totalPriceNoDiscount = ((puzzlesCount * puzzlesPrice) + (talkinDollsCount * talkinDollsPrice) + (teddyBearsCount * teddyBearsPrice) + ( minionsCount * minionsPrice) +
  24. (trucksCount * trucksPrice )) * 0.90;
  25.  
  26.  
  27.  
  28. double totalPriceDiscount = (((puzzlesCount * puzzlesPrice) + (talkinDollsCount * talkinDollsPrice) + (teddyBearsCount * teddyBearsPrice) + ( minionsCount * minionsPrice) +
  29. (trucksCount * trucksPrice )) * 0.75) * 0.90;
  30. int allToysCount = puzzlesCount + talkinDollsCount + teddyBearsCount + minionsCount + trucksCount;
  31.  
  32. if (allToysCount >= 50 || vacationPrice < totalPriceDiscount) {
  33. double moneyEnoughtDiff = totalPriceDiscount - vacationPrice;
  34.  
  35. System.out.printf("Yes! " + "%.2f" + " lv left.", moneyEnoughtDiff);
  36. //"Yes! {оставащите пари} lv left."
  37.  
  38.  
  39. } if (allToysCount < 50 || vacationPrice > totalPriceNoDiscount) {
  40. double moneyNotEnoughtDiff = vacationPrice - totalPriceNoDiscount;
  41.  
  42.  
  43. System.out.printf("Not enough money! " + "%.2f" + " lv needed." , moneyNotEnoughtDiff );
  44.  
  45. //o "Not enough money! {недостигащите пари} lv needed."
  46. }
  47.  
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement