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, dayOfWeek;
- double quantity, price;
- cin >> fruit >> dayOfWeek >> quantity;
- price = 0;
- cout.setf(ios::fixed);
- cout.precision(2);
- if (dayOfWeek == "Monday" || dayOfWeek == "Tuesday" || dayOfWeek == "Wednesday" || dayOfWeek == "Thursday" || dayOfWeek == "Friday")
- {
- if (fruit == "banana")
- {
- price = 2.5 * quantity;
- cout << price;
- }
- else if (fruit == "apple")
- {
- price = 1.2 * quantity;
- cout << price;
- }
- else if (fruit == "orange")
- {
- price = 0.85 * quantity;
- cout << price;
- }
- else if (fruit == "grapefruit")
- {
- price = 1.45 * quantity;
- cout << price;
- }
- else if (fruit == "kiwi")
- {
- price = 2.7 * quantity;
- cout << price;
- }
- else if (fruit == "pineapple")
- {
- price = 5.5 * quantity;
- cout << price;
- }
- else if (fruit == "grapes")
- {
- price = 3.85 * quantity;
- cout << price;
- }
- else
- {
- cout << "error" << endl;
- }
- }
- else if (dayOfWeek == "Saturday" || dayOfWeek == "Sunday")
- {
- if (fruit == "banana")
- {
- price = 2.7 * quantity;
- cout << price;
- }
- else if (fruit == "apple")
- {
- price = 1.25 * quantity;
- cout << price;
- }
- else if (fruit == "orange")
- {
- price = 0.90 * quantity;
- cout << price;
- }
- else if (fruit == "grapefruit")
- {
- price = 1.6 * quantity;
- cout << price;
- }
- else if (fruit == "kiwi")
- {
- price = 3 * quantity;;
- cout << price;
- }
- else if (fruit == "pineapple")
- {
- price = 5.6 * quantity;
- cout << price;
- }
- else if (fruit == "grapes")
- {
- price = 4.2 * quantity;
- cout << price;
- }
- else
- {
- cout << "error" << endl;
- }
- }
- else
- {
- cout << "error" << endl;
- }
- //cout.setf(ios::fixed);
- //cout.precision(2);
- //cout << price * quantity << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement