desislava_topuzakova

08. Toy Shop

Apr 25th, 2020
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.52 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ToyShop {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double holidayCost = Double.parseDouble(scanner.nextLine());
  8.         int puzzels = Integer.parseInt(scanner.nextLine());
  9.         int talkingDolls = Integer.parseInt(scanner.nextLine());
  10.         int teddyBears = Integer.parseInt(scanner.nextLine());
  11.         int minions = Integer.parseInt(scanner.nextLine());
  12.         int trucks = Integer.parseInt(scanner.nextLine());
  13.  
  14.         double puzzelsPrice = 2.60;
  15.         int talkingDollsPrice = 3;
  16.         double teddyBearsPrice = 4.10;
  17.         double minionsPrice = 8.20;
  18.         int trucksPrice = 2;
  19.  
  20.         double toysCost = puzzels * puzzelsPrice
  21.                 + talkingDolls * talkingDollsPrice
  22.                 + teddyBears * teddyBearsPrice
  23.                 + minions * minionsPrice
  24.                 + trucks * trucksPrice;
  25.         double toysQty = puzzels + talkingDolls + teddyBears + minions + trucks;
  26.         if (toysQty >= 50) {
  27.             toysCost = toysCost - 0.25 * toysCost ;
  28.            
  29.         }
  30.          double rent = 0.1 * toysCost  ;
  31.             double profit = toysCost  - rent;
  32.             double leftProfit = profit - holidayCost;
  33.                 if(leftProfit >= 0){
  34.                     System.out.printf("Yes! %.2f lv left.", leftProfit);
  35.                 } else {
  36.                     System.out.printf("Not enough money! %.2f lv needed.", Math.abs(leftProfit));
  37.                 }
  38.            
  39.     }
  40. }
Add Comment
Please, Sign In to add comment