Advertisement
MladenKarachanov

ToyShop

Nov 13th, 2022
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. package firstStepsInCoding.MoreExercises;
  2.  
  3. import com.sun.jdi.PathSearchingVirtualMachine;
  4.  
  5. import java.util.Scanner;
  6.  
  7. public class ToyShop {
  8. public static void main(String[] args) {
  9. Scanner scanner = new Scanner(System.in);
  10. double holiday = Double.parseDouble(scanner.nextLine());
  11. int numPuzzles = Integer.parseInt(scanner.nextLine());
  12. int numDolls = Integer.parseInt(scanner.nextLine());
  13. int numTeddyBears = Integer.parseInt(scanner.nextLine());
  14. int numMinions = Integer.parseInt(scanner.nextLine());
  15. int numTrucks = Integer.parseInt(scanner.nextLine());
  16. // Пъзел - 2.60 лв.
  17. // Говореща кукла - 3 лв.
  18. // Плюшено мече - 4.10 лв.
  19. // Миньон - 8.20 лв.
  20. // Камионче - 2 лв.
  21. double onePuzzle = 2.60;
  22. double oneDolls = 3.0;
  23. double oneTeddyBears = 4.10;
  24. double oneMinions = 8.20;
  25. double oneTrucks = 2.00;
  26. double sum = numPuzzles * onePuzzle + numDolls * oneDolls
  27. + numTeddyBears * oneTeddyBears
  28. + numMinions * oneMinions + numTrucks * oneTrucks;
  29. double numToys = numPuzzles + numDolls + numTeddyBears
  30. + numMinions + numTrucks;
  31. double discount = 0;
  32. double rent = 0;
  33. if (numToys >= 50) {
  34. discount = sum * 25 / 100;
  35. }
  36. double result = sum - discount;
  37. double finish = result * 0.1;
  38. double totalFinish = result - finish;
  39. double diff = Math.abs(totalFinish - holiday);
  40. if (totalFinish >=holiday) {
  41. System.out.printf("Yes! %.2f lv left.", diff);
  42.  
  43. } else {
  44. System.out.printf("Not enough money! %.2f lv needed.", diff);
  45. }
  46. }
  47. }
  48.  
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement