didkoslawow

Untitled

Sep 25th, 2022
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. function fuelTank2(input) {
  2.  
  3. let fuelType = input[0];
  4. let fuelQty = Number(input[1]);
  5. let clubCard = input[2];
  6.  
  7. let fuelPrice = 0;
  8.  
  9. switch(fuelType) {
  10. case "Gas":
  11. fuelPrice = 0.93;
  12. if (clubCard === "Yes") {
  13. fuelPrice = fuelPrice - 0.08;
  14. }
  15. break;
  16. case "Gasoline":
  17. fuelPrice = 2.22;
  18. if (clubCard === "Yes") {
  19. fuelPrice = fuelPrice - 0.12;
  20. }
  21. break;
  22. case "Diesel":
  23. fuelPrice = 2.33;
  24. if (clubCard === "Yes") {
  25. fuelPrice = fuelPrice - 0.18;
  26. }
  27. break;
  28. }
  29. let totalPrice = fuelQty * fuelPrice;
  30.  
  31. if (20 <= fuelQty && fuelQty <= 25) {
  32. totalPrice = totalPrice * 0.92;
  33. } else if (fuelQty > 25) {
  34. totalPrice = totalPrice * 0.90;
  35. }
  36.  
  37. console.log(totalPrice.toFixed(2) + " lv.");
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment