Please include Flowchart/Comments Direction: Choose one (1) of the two (2) proje
ID: 3605195 • Letter: P
Question
Please include Flowchart/Comments
Direction: Choose one (1) of the two (2) project choices. For each project, you are required to create at least four (4) functions excluding the main function. Likewise, the main function body should conist ONLY of variable declaration, assignments, and function calls; the main function should not directly preform any calculations or displays. Submit the full source code with documentation to receive points. Menu Receipt Applebee's Two for Twenty Two Entrées + One Appetizer Appetizer Two Caesar Side Salads Spinach Artichoke Dip Crunchy Onion Rings Boneless Wings Mozzarella Sticks Entré Chicken Tenders Basket Oriental Chicken Salad Firecracker Shrimp Cavatappi The American Standard Blackened Tilapia Whisky Bacon Burger Double-Glazed Baby Back Ribs- Half Rack (550 Cal.) [Phus 3.50 Cedar Grilled Lemon Chicken Fiesta Lime Chicken Three-Cheese Chicken Cavatappi (800 Cal.) (960 Cal.) (1300 Cal.) (1160 Cal.) (910 Cal.) (1150 Cal.) (1420 Cal.) (1970 Cal.) (1010 Cal) (510 Cal.) (1240 Cal.) (Plus 3.50) (580 Cal.) (1140 Cal.) (1280 Cal.) Your progran should 1. Display a list of appesizers and allow the user to select one (1). If the user's selection is invalid, give the user the "Two Caesar Side Salads 2. Display a list of entrées and allow the user to select two (2) separately. For any invalid selection, give the user the 3. Calculate the user's sul total tax 8 87. total, 15% 18% and 20% gratnity; and then display a spatially formatted 4. "Print the receipt to a file named "receipt.txt as well display it on the screen. "Chicken Tenders Basket receipt with the user's order and the above values rounded to two deciinal places Stats.h n Repostoryh readmepdf A Mean.h ^Explanation / Answer
#include<bits/stdc++.h>
using namespace std;
class food{
float price;
string name;
int calorie ;
string type;
public:
//setter function for food objs
void setfood(float lprice,string lname,int lcalorie,string ltype)
{
price=lprice;
name=lname;
calorie=lcalorie;
type=ltype;
}
//getter functions
float getprice(){
return price;
}
string getname(){
return name;
}
int getcalorie(){
return calorie;
}
string gettype()
{
return type;
}
void display_food()
{
cout<<setw(30);
cout<<getname()<<" "<<setw(7)<<getcalorie()<<endl;
}
};
//calulates the bill
void bill(vector<food> foods,float tax_rate,float g1,float g2,float g3)
{
cout<<"Ordered foods are........."<<endl;
cout<<setw(30)<<"Name"<<" "<<setw(7)<<"price"<<endl;
float subtotal,tax,total;
ofstream fs("receipt.txt");
if(!fs)
{
std::cerr<<"Cannot open the output file."<<std::endl;
}
for(int i=0;i<3;i++)
{
cout<<setw(30)<<foods[i].getname()<<" "<<setw(7)<<foods[i].getprice()<<endl;
subtotal+=foods[i].getprice();
fs<<setw(30)<<foods[i].getname()<<" "<<setw(7)<<foods[i].getprice()<<endl;
}
cout<<setw(30)<<"Subtotal"<<" "<<setw(7)<<subtotal<<endl;
fs<<setw(30)<<"Subtotal"<<" "<<setw(7)<<subtotal<<endl;
tax=subtotal*tax_rate;
cout<<setw(30)<<"Tax"<<" "<<setw(7)<<tax<<endl;
fs<<setw(30)<<"Tax"<<" "<<setw(7)<<tax<<endl;
total=subtotal+tax;
cout<<setw(30)<<"Total"<<" "<<setw(7)<<total<<endl;
fs<<setw(30)<<"Total"<<" "<<setw(7)<<total<<endl;
g1=total*g1;
cout<<setw(30)<<"Gratuity of 15 %"<<" "<<setw(7)<<g1<<endl;
fs<<setw(30)<<"Gratuity of 15 %"<<" "<<setw(7)<<g1<<endl;
g2=total*g2;
cout<<setw(30)<<"Gratuity of 18 %"<<" "<<setw(7)<<g2<<endl;
fs<<setw(30)<<"Gratuity of 18 %"<<" "<<setw(7)<<g2<<endl;
g3=total*g3;
cout<<setw(30)<<"Gratuity of 20 %"<<" "<<setw(7)<<g3<<endl;
fs<<setw(30)<<"Gratuity of 20 %"<<" "<<setw(7)<<g3<<endl;
fs.close();
}
int main(){
food foods[15];//Objects of food type will store all the details about food
float tax=0.0887;//tax-rate
vector<food> order;//list of all ordered food
//gratuity rate
float gratuity1=0.15,gratuity2=0.18,gratuity3=0.20;
//all details about foods are stored in array
float price_app[]={100.67,200,300.32,400.76,500};
float price_Entre[]={100.67,200,300,400.98,500,600.43,700,800.09,900,1000.55};
string name_app[]={"Two Caesar Side Salads","Spinach+ Artichoke Dip","Crunchy Onion Rings","Boneless Wings","Mozzarella sticks"};
string name_Entre[]={"Chicken Tenders Basket","Oriental Chicken Salad ","FireCracker Shrimp Cavatappi","THe American Standard","Blackened Tilapia","Two Caesar Side Salads","Whisky Bacon Burger ","DoubleGlazard Baby back RIles-Half Rack","Cadar Grilled Lemon Chicken","Fista LIme Chicken","Three-CheeseChicken Cavatappi "};
int calorie_app[]={800,960,1300,1160,910};
int calorie_Entre[]={1150,1420,1970,1010,510,1240,550,550,1140,1280};
//initialising the food objects with the data of stored in arrays
int i;
for(i=0;i<5;i++)
{
foods[i].setfood(price_app[i],name_app[i],calorie_app[i],"Appetizer");
}
for(i=0;i<10;i++)
{
foods[i+5].setfood(price_Entre[i],name_Entre[i],calorie_Entre[i],"Entre");
}
//dispalying the menu
int choice ;//order no
cout<<setw(38)<<"Appetizer"<<endl<<endl<<endl;
cout<<setw(30)<<"Food"<<" "<<setw(7)<<"calorie"<<endl;
cout<<setw(30)<<"_____________________________________________________"<<endl;
for(i=0;i<5;i++)
foods[i].display_food();
//checking invalid entry
cin>>choice;
if(choice>5||choice<0)
choice=1;
order.push_back(foods[choice-1]);
cout<<setw(38)<<"Appetizer"<<endl<<endl<<endl;
cout<<setw(30)<<"Food"<<" "<<setw(7)<<"calorie"<<endl;
cout<<setw(30)<<"_____________________________________________________"<<endl;
for(i=0;i<5;i++)
foods[i].display_food();
cin>>choice;
//checking invalid entry
if(choice>10||choice<0)
choice=6;
order.push_back(foods[choice-1]);
cout<<setw(38)<<"Entre"<<endl<<endl<<endl;
cout<<setw(30)<<"Food"<<" "<<setw(7)<<"calorie"<<endl;
cout<<setw(30)<<"_____________________________________________________"<<endl;
for(i=5;i<15;i++)
foods[i].display_food();
cin>>choice;
order.push_back(foods[5+choice-1]);
//calulating the total bill
bill(order,tax,gratuity1,gratuity2,gratuity3);
}