Question: C++ Modify the program so that it uses two void functions : one to calculate the price of a medium pizza and the other to
C++
Modify the program so that it uses two void functions : one to calculate the price of a medium pizza and the other to calculate the price of a large pizza. In addition to the $2 coupon on the purchase of a large pizza, Sophia is now emailing customers a $1 coupon on the purchase of a medium pizza. Test the program appropriately.
#include
int main() { char size = ' '; char coupon = ' '; double price = 0.0; cout << "M(edium or L(arge pizza? "; cin >> size; size = toupper(size);
if (size != 'M' && size != 'L') cout << "Please enter either M or L. " << endl; else { if (size == 'M') price = 9.99; else { price = 12.99; cout << "$2 dollar coupon (Y/N)? "; cin >> coupon; if (toupper(coupon) == 'Y') price -= 2;
} cout << fixed << setprecision(2); cout << "Price: $" << price << endl; } system("pause"); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
