Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please i need help to code this program with an output. in this exercise, you wi

ID: 3840837 • Letter: P

Question

Please i need help to code this program with an output.

in this exercise, you will modify the program that you createdin the chapter 6's lab 6-2. If necessary create a newproject named Intermediate21 oroject, and save it in the cpp8Chap09 folder. copy the instructions from lab 6-2.cpp file into a source file named Intermediate21.cpp. Change the file name in the first commnet. Dodify the program so that it uses two value-returning functions: one to calculate and return the price of a medium pizza and the other to calculate and return the price of large pizza. In addition to the $2 coupon on the purchase of a large pizza. Sophia is now emailing a customers a $1 coupon on the purchase of a medium pizza. Test the program appropriately.

Here is the lab 6-2

Lab 6-2 1 //Lab6-2.cpp displays the price of a pizza. 2 Created/revised by kyour name> on

Explanation / Answer

C++ Code:

#include<iostream>
#include<iomanip>
using namespace std;
double Medium()
{ char coupon = ' ';
   double price = 9.99;
   cout<<"$1 coupon (Y/N)? ";
   cin>>coupon;
   if(toupper(coupon)=='Y')
   price -= 1;
   return price;
}
double Large()
{ char coupon = ' ';
   double price = 12.99;
   cout<<"$2 coupon (Y/N)? ";
   cin>>coupon;
   if(toupper(coupon)=='Y')
   price -= 2;
   return price;
}
int main()
{
   char size,coupon;
   double price =0.0;
   cout<<"M(edium) or L(arge) pizza? "<<endl;
   cin>>size;
   size=toupper(size);
  
   if(size != 'M' && size != 'L')
   cout<<"Please enter either M or L."<<endl;
   else
   {
       if(size == 'M')
       price = Medium();
       else
       price = Large();
   }
   cout<<fixed<<setprecision(2);
   cout<<"Price: $"<<price<<endl;
   return 0;
}

Output:

M(edium) or L(arge) pizza?
M
$1 coupon (Y/N)? Y
Price: $8.99

M(edium) or L(arge) pizza?
L
$2 coupon (Y/N)? Y
Price: $10.99