desislava_topuzakova

Untitled

Apr 4th, 2021
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ToyShop_07 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. double tripePrice = Double.parseDouble(scanner.nextLine());
  8. int puzzleCount = Integer.parseInt(scanner.nextLine());
  9. int speakDogCount = Integer.parseInt(scanner.nextLine());
  10. int plushBearCount = Integer.parseInt(scanner.nextLine());
  11. int minionsCount = Integer.parseInt(scanner.nextLine());
  12. int trucksCount = Integer.parseInt(scanner.nextLine());
  13.  
  14. double puzzlePrice = puzzleCount * 2.6;
  15. int speakDogPrice = speakDogCount * 3;
  16. double plushBearPrice = plushBearCount * 4.1;
  17. double minionPrice = minionsCount * 8.2;
  18. int truckPrice = trucksCount * 2;
  19.  
  20. double totalPriceToy = puzzlePrice + speakDogPrice
  21. + plushBearPrice + minionPrice + truckPrice;
  22.  
  23. int totalToy = puzzleCount + speakDogCount + plushBearCount
  24. + minionsCount + trucksCount;
  25.  
  26. if (totalToy > 50) {
  27. double afterDiscount = totalPriceToy * 0.25;
  28. totalPriceToy = totalPriceToy - afterDiscount;
  29. }
  30. double rentHall = totalPriceToy * 0.10;
  31. double totalAfterCosts = totalPriceToy - rentHall;
  32. if(totalAfterCosts >= tripePrice){
  33. double leftMoney = totalAfterCosts - tripePrice;
  34. System.out.printf("Yes! %.2f lv left.", leftMoney);
  35. } else {
  36. double leftMoney1 = tripePrice - totalAfterCosts ;
  37. System.out.printf("Not enough money! %.2f lv needed.",leftMoney1);
  38. }
  39.  
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment