Advertisement
stoyanoff

Toy Shop

Jun 10th, 2020
1,130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.14 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ToyShop_07 {
  4.     public static void main(String[] args) {
  5.         Scanner myScan = new Scanner(System.in);
  6.  
  7.         // Toys Prices
  8.  
  9.         double puzzlePrice = 2.6;
  10.         double dollPrice = 3;
  11.         double teddyBearPrice = 4.1;
  12.         double minionToyPrice = 8.2;
  13.         double truckToyPrice = 2;
  14.  
  15.         // Incoming data
  16.  
  17.         double excursionPrice = Double.parseDouble(myScan.nextLine());
  18.         int puzzleOrder = Integer.parseInt(myScan.nextLine());
  19.         int dollsOrder =  Integer.parseInt(myScan.nextLine());
  20.         int teddyBearOrder =  Integer.parseInt(myScan.nextLine());
  21.         int minionToyOrder =  Integer.parseInt(myScan.nextLine());
  22.         int truckToyOrder = Integer.parseInt(myScan.nextLine());
  23.  
  24.         // calculating how many toys are ordered
  25.         int toysOrder = puzzleOrder + dollsOrder + teddyBearOrder + minionToyOrder + truckToyOrder;
  26.         double revenue = (puzzleOrder * puzzlePrice + dollPrice * dollsOrder + teddyBearOrder * teddyBearPrice + minionToyOrder * minionToyPrice + truckToyOrder * truckToyPrice);
  27.         // if the toys are 50 or more there is 25% discount & 10% from the revenue is for rent
  28.         if (toysOrder >= 50) {
  29.             // discount 25%
  30.             double income = revenue * 0.75;
  31.             // removing the rent
  32.             double totalRevenue = income * 0.9;
  33.            
  34.                 if (totalRevenue >= excursionPrice) {
  35.                 System.out.printf("Yes! %.2f lv left.", (totalRevenue - excursionPrice));
  36.             } else {
  37.                     double missingRevenue = excursionPrice - totalRevenue;
  38.                 System.out.printf("Not enough money! %.2f lv needed.", missingRevenue);
  39.             }
  40.  
  41.  
  42.         } else {
  43.             double income = revenue * 0.9;
  44.               if (income >= excursionPrice){
  45.                   System.out.printf("Yes! %.2f lv left.", (income - excursionPrice));
  46.               } else {
  47.                   double missingRevenue = excursionPrice - income;
  48.                   System.out.printf("Not enough money! %.2f lv needed.", missingRevenue);
  49.               }
  50.  
  51.  
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement