Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- const double GAS_PRICE = 0.93;
- const double DIESEL_PRICE = 2.33;
- const double GASOLINE_PRICE = 2.22;
- string fuel;
- cin >> fuel;
- double liters;
- cin >> liters;
- string card;
- cin >> card;
- double cardDiscount = card == "Yes" ? (fuel == "Gasoline" ? 0.18 : fuel == "Diesel" ? 0.12 : 0.08) : 0;
- double quantitativeDiscount = liters > 25 ? 0.10 : liters >= 20 ? 0.08 : 0;
- double totalSum = (((fuel == "Gas" ? GAS_PRICE : fuel == "Diesel" ? DIESEL_PRICE : GASOLINE_PRICE) - cardDiscount) * liters) * (1 - quantitativeDiscount);
- cout.setf(ios::fixed);
- cout.precision(2);
- cout << totalSum << " lv." << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement