Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- string fruit, day;
- cin >> fruit >> day;
- double quantity;
- cin >> quantity;
- double price = 0;
- if (day == "Monday" || day == "Tuesday" || day == "Wednesday" || day == "Thursday" || day == "Friday") {
- price =
- fruit == "banana" ? 2.5 :
- fruit == "apple" ? 1.2 :
- fruit == "orange" ? 0.85 :
- fruit == "grapefruit" ? 1.45 :
- fruit == "kiwi" ? 2.7 :
- fruit == "pineapple" ? 5.5 :
- fruit == "grapes" ? 3.85 : 0;
- }
- else if (day == "Saturday" || day == "Sunday") {
- price =
- fruit == "banana" ? 2.7 :
- fruit == "apple" ? 1.25 :
- fruit == "orange" ? 0.9 :
- fruit == "grapefruit" ? 1.6 :
- fruit == "kiwi" ? 3 :
- fruit == "pineapple" ? 5.6 :
- fruit == "grapes" ? 4.2 : 0;
- }
- cout.setf(ios::fixed);
- cout.precision(2);
- if (price > 0) {
- cout << price * quantity << endl;
- }
- else {
- cout << "error" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement