I'm supposed to create a bill for a catering group utilizing at least two functions, which functions could I use for this and how will I use them? I've done it with mainly if and else statements and simple calculations, any functions I can use?
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
int main()
{
int adults;
int children;
double ameals;
double cmeals;
char mealtype;
char weekend;
string mealtype2;
double deposit;
double dmeals=15.80;
double smeals=11.75;
double foodtotal;
double surcharge;
double totalbill;
double discount;
double taxtip;
cout<<"How many adults? ";
cin>>adults;
cout<<"How many children? ";
cin>>children;
cout<<"Deluxe meals or standard meals? (D/S) ";
cin>>mealtype;
cout<<"Weekend? (Y/N) ";
cin>>weekend;
cout<<"Deposit amount: ";
cin>>deposit;
{
if (mealtype=='D')
foodtotal=dmeals*adults+dmeals*0.6*children;
ameals=dmeals*adults;
cmeals=dmeals*0.6*children;
mealtype2="Deluxe";
if (mealtype=='S')
foodtotal=smeals*adults+smeals*0.6*children;
ameals=dmeals*adults;
cmeals=dmeals*0.6*children;
mealtype2="Standard";
}
taxtip=0.18*foodtotal;
totalbill=foodtotal+taxtip;
if (weekend=='Y')
{
surcharge=totalbill*0.07;
totalbill=totalbill+surcharge;
}
else
surcharge=0;
if (totalbill<100)
discount=totalbill*0.015;
else if (totalbill>=100 && totalbill<400)
discount=totalbill*0.025;
else
discount=totalbill*0.035;
cout<<fixed<<showpoint<<setprecision(2);
cout<<"Number of adults: \t"<<adults<<setw(7)<<endl;
cout<<"Number of children: \t"<<children<<setw(7)<<endl;
cout<<"Meal Type: \t\t"<<mealtype2<<setw(7)<<endl;
cout<<"Adult meal cost:\t"<<ameals<<setw(7)<<endl;
cout<<"Children meal cost:\t"<<cmeals<<setw(7)<<endl;
cout<<"Surcharge: \t\t"<<surcharge<<setw(7)<<endl;
cout<<"Tax and Tip: \t\t"<<taxtip<<setw(7)<<endl;
cout<<"Deposit: \t\t"<<deposit<<setw(7)<<endl;
cout<<"Total Balance Due: \t"<<totalbill<<setw(7)<<endl;
cout<<"Discount: \t\t"<<discount<<setw(7)<<endl;
return 0;
}