Advertisement
Gin10

Untitled

Feb 18th, 2020
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ToyShop_08 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. //input -> holiday, puzzles, dolls, bears, minions, trucks
  7. //price -> p - 2.6, d - 3, b - 4.1, m - 8.20, t - 2
  8. double holiday = Double.parseDouble(scanner.nextLine());
  9. int puzzles = Integer.parseInt(scanner.nextLine());
  10. int bears = Integer.parseInt(scanner.nextLine());
  11. int dolls = Integer.parseInt(scanner.nextLine());
  12. int minions = Integer.parseInt(scanner.nextLine());
  13. int trucks = Integer.parseInt(scanner.nextLine());
  14. int toys = puzzles + bears + dolls + minions + trucks;
  15. double priceToys = (puzzles * 2.6) + (dolls * 3) + (bears * 4.1) + (minions * 8.20) + (trucks * 2);
  16. if (toys >= 50) {
  17. double dis = priceToys * 0.75;
  18. double finalPrice = priceToys - dis;
  19. double rent = finalPrice * 0.1;
  20. double earnMoney = finalPrice - rent;
  21. if (earnMoney >= holiday) {
  22. System.out.printf("Yes! %.2f lv left.", earnMoney);
  23. } else {
  24. System.out.printf("Not enough money! %.2f lv needed.", earnMoney);
  25. }
  26. } else {
  27. double finalPrice = priceToys * 1;
  28. double rent = finalPrice * 0.1;
  29. double earnMoney = finalPrice - rent;
  30. if (earnMoney < holiday) {
  31. System.out.printf("Not enough money! %.2f lv needed.", earnMoney);
  32. } else {
  33. System.out.printf("Yes! %.2f lv left.", earnMoney);
  34. }
  35.  
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement