galinyotsev123

ProgBasics03Conditional-Statements-P10ToyShop

Jan 11th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P10ToyShop {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. double PuzzlePrice = 2.60;
  8. double DollsPrice = 3;
  9. double BearsPrice = 4.10;
  10. double MinionsPrice = 8.20;
  11. double LorryPrice = 2;
  12.  
  13. double TripPrice = Double.parseDouble(scanner.nextLine());
  14. int PuzzlesCount = Integer.parseInt(scanner.nextLine());
  15. int DollsCount = Integer.parseInt(scanner.nextLine());
  16. int BearsCount = Integer.parseInt(scanner.nextLine());
  17. int MinionsCount = Integer.parseInt(scanner.nextLine());
  18. int LorryCount = Integer.parseInt(scanner.nextLine());
  19.  
  20. double PuzzlesTotalPice = PuzzlePrice * PuzzlesCount;
  21. double DollsTotalPrice = DollsPrice * DollsCount;
  22. double BearsTotalPrice = BearsPrice * BearsCount;
  23. double MinionsTotalPrice = MinionsPrice * MinionsCount;
  24. double LorryTotalPrice = LorryPrice * LorryCount;
  25.  
  26. int TotalToysCount = PuzzlesCount + DollsCount + BearsCount + MinionsCount + LorryCount;
  27.  
  28. double TotalToysPrice = PuzzlesTotalPice + DollsTotalPrice + BearsTotalPrice + MinionsTotalPrice + LorryTotalPrice;
  29.  
  30.  
  31. if(TotalToysCount >= 50){
  32. TotalToysPrice = TotalToysPrice * 0.75;
  33. }
  34. TotalToysPrice = TotalToysPrice * 0.9;
  35.  
  36. double diff = TotalToysPrice - TripPrice;
  37.  
  38. if (diff < 0) {
  39. System.out.printf("Not enough money! %.2f lv needed.", Math.abs(diff));
  40. } else {
  41. System.out.printf("Yes! %.2f lv left.", diff); }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment