Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class toyShop {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6.  
  7. double priceOfTrip = Double.parseDouble(scan.nextLine());
  8. int puzzles = Integer.parseInt(scan.nextLine());
  9. int dolls = Integer.parseInt(scan.nextLine());
  10. int bears = Integer.parseInt(scan.nextLine());
  11. int minions = Integer.parseInt(scan.nextLine());
  12. int trucks = Integer.parseInt(scan.nextLine());
  13.  
  14. double priceForOnePuzzle = 2.60;
  15. double priceForOneDoll = 3.00;
  16. double priceForOneBear = 4.10;
  17. double priceForOneMinion = 8.20;
  18. double priceForOneTruck = 2.00;
  19.  
  20. double price = puzzles * priceForOnePuzzle + dolls * priceForOneDoll + bears * priceForOneBear + minions * priceForOneMinion + trucks * priceForOneTruck;
  21.  
  22. int toys = puzzles + dolls + bears + minions + trucks;
  23. if(toys > 50){
  24. price = price * 0.75;
  25. }
  26. double pechalba = price * 0.9;
  27.  
  28. if(pechalba > priceOfTrip){
  29. System.out.printf("Yes! %.2f lv left.", pechalba - priceOfTrip);
  30. }
  31. else{
  32. System.out.printf("Not enough money! %.2f lv needed.", priceOfTrip - pechalba);
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement