Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fuelTank2(input) {
- let fuelType = input[0];
- let fuelQty = Number(input[1]);
- let clubCard = input[2];
- let fuelPrice = 0;
- switch(fuelType) {
- case "Gas":
- fuelPrice = 0.93;
- if (clubCard === "Yes") {
- fuelPrice = fuelPrice - 0.08;
- }
- break;
- case "Gasoline":
- fuelPrice = 2.22;
- if (clubCard === "Yes") {
- fuelPrice = fuelPrice - 0.12;
- }
- break;
- case "Diesel":
- fuelPrice = 2.33;
- if (clubCard === "Yes") {
- fuelPrice = fuelPrice - 0.18;
- }
- break;
- }
- let totalPrice = fuelQty * fuelPrice;
- if (20 <= fuelQty && fuelQty <= 25) {
- totalPrice = totalPrice * 0.92;
- } else if (fuelQty > 25) {
- totalPrice = totalPrice * 0.90;
- }
- console.log(totalPrice.toFixed(2) + " lv.");
- }
Advertisement
Add Comment
Please, Sign In to add comment