Advertisement
IvaAnd

Toy Shop

Feb 17th, 2020
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.26 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.         // READ:
  8.         //1. price of excursion -> double
  9.         //2. number of puzzles -> int
  10.         //3. number of dolls -> int
  11.         //4. number of bears -> int
  12.         //5. number of minions -> int
  13.         //6. number of trucks -> int
  14.  
  15.         double excursionPrice = Double.parseDouble(scanner.nextLine());
  16.         int nOfPuzzles = Integer.parseInt(scanner.nextLine());
  17.         int nOfDolls = Integer.parseInt(scanner.nextLine());
  18.         int nOfBears = Integer.parseInt(scanner.nextLine());
  19.         int nOfMinions = Integer.parseInt(scanner.nextLine());
  20.         int nOfTrucks = Integer.parseInt(scanner.nextLine());
  21.  
  22.         // Calculate price of an order - > number of toys * price (given)
  23.         double totalPricePuzzles = nOfPuzzles * 2.60;
  24.         int totalPriceDolls = nOfDolls * 3;
  25.         double totalPriceBears = nOfBears * 4.10;
  26.         double totalPriceMinions = nOfMinions * 8.20;
  27.         int totalPriceTrucks = nOfTrucks * 2;
  28.  
  29.         double totalNOfToys = nOfPuzzles + nOfDolls + nOfBears + nOfMinions + nOfTrucks;
  30.         double totalPriceOfOrder = totalPricePuzzles + totalPriceDolls + totalPriceBears + totalPriceMinions + totalPriceTrucks;
  31.         double afterRent = totalPriceOfOrder * 0.9;
  32.  
  33.         if (totalNOfToys >= 50) {
  34.             // calculate total after discount = Tot Price Of order - 25% discount
  35.             double afterDiscount = totalPriceOfOrder * 0.75;
  36.  
  37.             // Calculate total net after deducting for rent
  38.             double afterRent1 = afterDiscount * 0.9;
  39.  
  40.             //
  41.             if (excursionPrice < afterRent1) {
  42.                 System.out.printf("Yes! %.2f lv left.", afterRent1 - excursionPrice );
  43.             } else {
  44.                 System.out.printf("Not enough money! %.2f lv needed.", excursionPrice -afterRent);
  45.             }
  46.             }
  47.         else if (totalNOfToys < 50) {
  48.  
  49.         } if (excursionPrice < afterRent ) {
  50.             System.out.printf("Yes! %.2f lv left.", afterRent - excursionPrice );
  51.         } else {
  52.             System.out.printf("Not enough money! %.2f lv needed.", excursionPrice - afterRent);
  53.  
  54.         }
  55.  
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement