veronikaaa86

07. Toy Shop

May 15th, 2021
1,033
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package ConditionalStatements;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P06ToyShop {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         double tripPrice = Double.parseDouble(scanner.nextLine());
  10.         int puzzleCount = Integer.parseInt(scanner.nextLine());
  11.         int dollsCount = Integer.parseInt(scanner.nextLine());
  12.         int teddyCount = Integer.parseInt(scanner.nextLine());
  13.         int minionsCount = Integer.parseInt(scanner.nextLine());
  14.         int trucksCount = Integer.parseInt(scanner.nextLine());
  15.  
  16. //        •   Пъзел - 2.60 лв.
  17. //        •   Говореща кукла - 3 лв.
  18. //        •   Плюшено мече - 4.10 лв.
  19. //        •   Миньон - 8.20 лв.
  20. //        •   Камионче - 2 лв.
  21.  
  22.         double sum = (puzzleCount * 2.60) + (dollsCount * 3) + (teddyCount * 4.10) + (minionsCount * 8.20) + (trucksCount * 2.00);
  23.  
  24.         int countAllToys = puzzleCount + dollsCount + teddyCount + minionsCount + trucksCount;
  25.  
  26.         if (countAllToys >= 50) {
  27.             sum = sum * 0.75;
  28.         }
  29.  
  30.         sum = sum * 0.90;
  31.  
  32.         double diff = Math.abs(sum - tripPrice);
  33.         if (sum >= tripPrice) {
  34.             System.out.printf("Yes! %.2f lv left.", diff);
  35.         } else {
  36.             System.out.printf("Not enough money! %.2f lv needed.", diff);
  37.         }
  38.     }
  39. }
  40.  
RAW Paste Data