Advertisement
Guest User

Untitled

a guest
Jan 8th, 2023
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. let print = this.print || console.log;
  2.  
  3. let input = [
  4. '31',
  5. '115'];
  6.  
  7. let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
  8.  
  9. let totalMessages = +gets();
  10. let totalMinutes = +gets();
  11.  
  12. let billPlan = 12.00;
  13. let addMessages = 0;
  14. let addMinutes = 0;
  15. let addMessCost = 0;
  16. let addMinCost = 0;
  17. let tax = 0;
  18. let totalBill = 0;
  19.  
  20. if (totalMessages > 20 || totalMinutes > 60) {
  21.  
  22. addMessages = totalMessages - 20;
  23. addMinutes = totalMinutes - 60;
  24.  
  25. addMessCost = addMessages * 0.06;
  26. addMinCost = addMinutes * 0.10;
  27.  
  28. tax = 0.20 * (addMessCost + addMinCost);
  29.  
  30. totalBill = billPlan + addMessCost + addMinCost + tax;
  31.  
  32. } else {
  33. totalBill = billPlan;
  34. }
  35.  
  36. print(`${addMessages} additional messages for ${addMessCost.toFixed(2)} levas`);
  37. print(`${addMinutes} additional minutes for ${addMinCost.toFixed(2)} levas`);
  38. print(`${tax.toFixed(2)} additional tax`);
  39. print(`${totalBill.toFixed(2)} total bill`);
Tags: JavaScript
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement