Advertisement
popovIliya

March-2022-Conditional Statements - Exercise -Toy Shop

Mar 13th, 2022
1,185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function checking(input){
  2.   let  puzzlePrice = 2.60, priceTalkingDoll = 3.00, priceTedyBear = 4.10,
  3.    priceMinion = 8.20, priceTruck = 2.00, discount = 0.00, rent = 0.00, profit = 0.00;
  4.    let excursionPrice = Number(input[0]), puzzle = parseInt(input[1]), talkingDoll = parseInt(input[2]),
  5.    tedyBear = parseInt(input[3]), minion = parseInt(input[4]), truck = parseInt(input[5]);
  6.    let order = (puzzle + talkingDoll + tedyBear + minion + truck);
  7.    let amount = ((puzzle * puzzlePrice) + (talkingDoll * priceTalkingDoll) +
  8.    (tedyBear * priceTedyBear) + (minion * priceMinion) + (truck * priceTruck));
  9.    if(order >= 50){
  10.      discount = amount * 0.25;
  11.    }
  12.    rent = ((amount - discount) * 0.10);
  13.    profit = ((amount - discount) - rent);
  14.    if(profit >= excursionPrice){
  15.        console.log(`Yes! ${(profit - excursionPrice).toFixed(2)} lv left.`)
  16.    }
  17.    else{
  18.     console.log(`Not enough money! ${(excursionPrice - profit).toFixed(2)} lv needed.`)  
  19.    }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement