Advertisement
RRusev77

Fuel Tank 2

Mar 24th, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(fuelType, fuelVolume, clubCard){
  2.     fuelVolume = Number(fuelVolume);
  3.  
  4.     let gasolineLiterPrice, gasLiterPrice, dieselLiterPrice;
  5.     gasolineLiterPrice = 2.22;
  6.     gasLiterPrice = 0.93;
  7.     dieselLiterPrice = 2.33;
  8.    
  9.     if(clubCard === 'Yes') {
  10.         gasolineLiterPrice -= 0.18;
  11.         gasLiterPrice -= 0.08;
  12.         dieselLiterPrice -= 0.12;
  13.     }
  14.    
  15.     let gasolinePrice, gasPrice, dieselPrice;
  16.     gasolinePrice = gasolineLiterPrice * fuelVolume;
  17.     gasPrice = gasLiterPrice * fuelVolume;
  18.     dieselPrice = dieselLiterPrice * fuelVolume;
  19.  
  20.     if(fuelVolume > 20 && fuelVolume <= 25){
  21.         gasolinePrice *= 0.92;
  22.         gasPrice *= 0.92;
  23.         dieselPrice *= 0.92;
  24.     } else if(fuelVolume > 25) {
  25.         gasolinePrice *= 0.9;
  26.         gasPrice *= 0.9;
  27.         dieselPrice *= 0.9;
  28.     }
  29.  
  30.     if(fuelType === 'Gasoline') {
  31.         console.log(`${gasolinePrice.toFixed(2)} lv.`);
  32.     } else if (fuelType === 'Gas') {
  33.         console.log(`${gasPrice.toFixed(2)} lv.`);
  34.     } else if (fuelType === 'Diesel') {
  35.         console.log(`${dieselPrice.toFixed(2)} lv.`);
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement