didkoslawow

Agency Profit

Sep 12th, 2022 (edited)
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. function ticketsProfit(input) {
  2.  
  3. let avioCompanyName = input[0];
  4. let ticketsForAdults = Number(input[1]);
  5. let ticketsForChildren = Number(input[2]);
  6. let basePriceForAdult = Number(input[3]);
  7. let taxes = Number(input[4]);
  8.  
  9. let basePriceForChildren = basePriceForAdult - (basePriceForAdult * 0.70);
  10.  
  11. let totalPriceForAdults = basePriceForAdult + taxes;
  12. let totalPriceForChildren = basePriceForChildren + taxes;
  13.  
  14. let totalPriceForTickets = (totalPriceForAdults * ticketsForAdults) + (totalPriceForChildren * ticketsForChildren);
  15. let profitForAgency = (totalPriceForTickets * 0.20).toFixed(2);
  16.  
  17.  
  18. console.log(`The profit of your agency from ${avioCompanyName} tickets is ${profitForAgency} lv.`);
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment