Advertisement
veronikaaa86

04. Toy Shop

Jan 16th, 2022
668
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. package conditionalStatements;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P04ToyShop {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. double tripPrice = Double.parseDouble(scanner.nextLine());
  10. int puzzleCount = Integer.parseInt(scanner.nextLine());
  11. int dollsCount = Integer.parseInt(scanner.nextLine());
  12. int teddyCount = Integer.parseInt(scanner.nextLine());
  13. int minionsCount = Integer.parseInt(scanner.nextLine());
  14. int truckCount = Integer.parseInt(scanner.nextLine());
  15.  
  16. double allSum = (puzzleCount * 2.60) +
  17. (dollsCount * 3.0) +
  18. (teddyCount * 4.10) +
  19. (minionsCount * 8.20) +
  20. (truckCount * 2.0);
  21.  
  22. int countAllToys = puzzleCount + dollsCount + teddyCount + minionsCount + truckCount;
  23.  
  24. if (countAllToys >= 50) {
  25. allSum = allSum - (allSum * 0.25);
  26. }
  27.  
  28. allSum = allSum - (allSum * 0.10);
  29.  
  30. double diff = Math.abs(allSum - tripPrice);
  31. if (allSum >= tripPrice) {
  32. System.out.printf("Yes! %.2f lv left.", diff);
  33. } else {
  34. System.out.printf("Not enough money! %.2f lv needed.", diff);
  35. }
  36. }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement