Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fuelTank(input) {
- let gasoline = 2.22;
- let diesel = 2.33;
- let gas = 0.93;
- let fuelType = String(input[0]);
- let quantity = Number(input[1]);
- let discountCard = String(input[2]);
- let gasolinePrice = 0;
- let dieselPrice = 0;
- let gasPrice = 0;
- if (discountCard === "Yes" && fuelType === "Gasoline") {
- gasoline -= 0.18;
- } else if (discountCard === "Yes" && fuelType === "Diesel") {
- diesel -= 0.12;
- } else if (discountCard === "Yes" && fuelType === "Gas") {
- gas -= 0.08;
- } else {
- gasoline = 2.22;
- diesel = 2.33;
- gas = 0.93;
- }
- if (fuelType === "Gasoline") {
- if (quantity >= 20 && quantity <= 25) {
- gasolinePrice = (gasoline * quantity) * 0.92;
- } else if (quantity > 25){
- gasolinePrice = (gasoline * quantity) * 0.9;
- } else {
- gasolinePrice = gasoline * quantity;
- }
- console.log(`${gasolinePrice.toFixed(2)} lv.`);
- } else if (fuelType === "Diesel") {
- if (quantity >= 20 && quantity <= 25) {
- dieselPrice = (diesel * quantity) * 0.92;
- } else if (quantity > 25) {
- dieselPrice = (diesel * quantity) * 0.9;
- } else {
- dieselPrice = diesel * quantity;
- }
- console.log(`${dieselPrice.toFixed(2)} lv.`);
- } else if (fuelType === "Gas") {
- if (quantity >= 20 && quantity <= 25) {
- gasPrice = (gas * quantity) * 0.92;
- } else if (quantity > 25) {
- gasPrice = (gas * quantity) * 0.9;
- } else {
- gasPrice = gas * quantity;
- }
- console.log(`${gasPrice.toFixed(2)} lv.`);
- }
- }
Add Comment
Please, Sign In to add comment