Advertisement
avr39ripe

cppFuelCostComparision

Jan 19th, 2022
769
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.     double distance{ 100 };
  6.     double consumptionPer100km{10};
  7.     double a92{ 25.25 };
  8.     double a95{ 28.14 };
  9.     double a98{ 31.99 };
  10.     const int fuelConsumtionDiv{ 100 };
  11.  
  12.     double fuelVolume{};
  13.  
  14.     // ctrl + K + C - comment
  15.     // ctrl + K + U - uncomment
  16.  
  17.     std::cout << "Enter trip distance in km.\n";
  18.     std::cin >> distance;
  19.  
  20.     std::cout << "Enter fuel consumption per 100 km in liters\n";
  21.     std::cin >> consumptionPer100km;
  22.  
  23.     std::cout << "Enter A92 price in UAH.\n";
  24.     std::cin >> a92;
  25.  
  26.     std::cout << "Enter A95 price in UAH.\n";
  27.     std::cin >> a95;
  28.  
  29.     std::cout << "Enter A98 price in UAH.\n";
  30.     std::cin >> a98;
  31.  
  32.     fuelVolume = distance / fuelConsumtionDiv * consumptionPer100km;
  33.  
  34.     std::cout << "Trip on A92 will cost " << fuelVolume * a92 << "UAH\n";
  35.     std::cout << "Trip on A95 will cost " << fuelVolume * a95 << "UAH\n";
  36.     std::cout << "Trip on A98 will cost " << fuelVolume * a98 << "UAH\n";
  37.  
  38.     return 0;
  39. }
  40.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement