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