Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int main() {
- int kilometers;
- cin >> kilometers;
- string timeOfDay;
- cin >> timeOfDay;
- const double TAXI_STARTING_PRICE = 0.70;
- const double TAXI_PRICE_PER_KILOMETER = (timeOfDay == "day" ? 0.79 : 0.90);
- const double BUS_PRICE_PER_KILOMETER = 0.09;
- const double TRAIN_PRICE_PER_KILOMETER = 0.06;
- double taxiPrice = TAXI_STARTING_PRICE + TAXI_PRICE_PER_KILOMETER * kilometers;
- double busPrice = BUS_PRICE_PER_KILOMETER * kilometers;
- double trainPrice = TRAIN_PRICE_PER_KILOMETER * kilometers;
- double cheapestPrice = kilometers < 20 ? taxiPrice : kilometers < 100 ? busPrice : trainPrice;
- cout.setf(ios::fixed);
- cout.precision(2);
- cout << cheapestPrice << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement