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