Advertisement
Guest User

ToyShop

a guest
Sep 17th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7. public static void main(String[] args) {
  8. Scanner scan = new Scanner(System.in);
  9. double vacationCost = Double.parseDouble(scan.nextLine());
  10. int puzzleCount = Integer.parseInt(scan.nextLine());
  11. int dollsCount = Integer.parseInt(scan.nextLine());
  12. int bearsCount = Integer.parseInt(scan.nextLine());
  13. int minionsCount = Integer.parseInt(scan.nextLine());
  14. int trucksCount = Integer.parseInt(scan.nextLine());
  15.  
  16. double puzzle = 2.60;
  17. double dolls = 3;
  18. double bears = 4.10;
  19. double minion = 8.20;
  20. double truck = 2;
  21.  
  22. int totalToysCount = puzzleCount + dollsCount + bearsCount + minionsCount + trucksCount;
  23. double moneyFromToys = (puzzleCount * puzzle) +
  24. (dollsCount * dolls) +
  25. (bearsCount * bears) +
  26. (minionsCount * minion) +
  27. (trucksCount * truck);
  28. if (totalToysCount >= 50) {
  29. double otsypka = moneyFromToys * 0.25;
  30. moneyFromToys = moneyFromToys - otsypka;
  31. }
  32. double rent = moneyFromToys * 0.10;
  33. moneyFromToys = moneyFromToys - rent;
  34. if (moneyFromToys >= vacationCost) {
  35. double output = moneyFromToys - vacationCost;
  36. System.out.printf("Yes! %.2f lv left.", output);
  37. } else {
  38. double output = vacationCost - moneyFromToys;
  39. System.out.printf("Not enough money! %.2f lv needed.", output);
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement