I'm not sure whether one of my formulas are wrong, I placed something in the wrong area, or I'm missing something completely. But when I run the prog. It would add up the prices of meals from a previous table of customers, instead of resetting for each new table. Any help?
int main ()
{
//These are the variables used for the formulas and inputs.
int people, counter;
float price, subtotal, tip, tax, total;
cout<<"How many people are at the table?" <<endl;
cin>>people;
//Use a while statement to start a loop
while (people!=0)
{
//Use a for statement inside the while to make a nested loop. It will ask the price of each meal.
for(counter=1; counter<=people; counter++)
{
cout<<"How much is the meal?: " <<endl;
cin>>price;
subtotal+=price;
tax=subtotal*.06;
if (people<5)
{
tip=subtotal*.18;
}
else
tip=subtotal*.20;
total=tax+subtotal+tip;
}
//This is the final output for the program. Which will be the bill.
cout<<setprecision(2) <<fixed;
cout<<left;
cout<<setw(20)<<"Subtotal: " <<"$" <<subtotal <<endl;
cout<<setw(20)<<"Sales Tax: " <<"$" <<tax <<endl;
cout<<setw(20)<<"Tip: " <<"$" <<tip <<endl;
cout<<setw(20)<<"Total: " <<"$" <<total <<endl;
cout<<" " <<endl;
cout<<setw(20)<<"How many people are at the table?" <<endl;
cin>>people;
}