has a user input amount of items purchased
asks for input of all prices of items (all this in a while loop)
then sales tax
then figures out the total and outputs it.
#include <iostream>
usingnamespace std;
int main()
{
float items = 0, count = 0, price = 0, total = 0, percent, g_t, tax;//a lot of variables but all neseccary for this, some are place holders just to start counters, totals, ect.
char rerun;//our re-run option
cout<<"How many sales items do you have? :";
cin>>items;
do//the do-while for a program rerun option
{
while ( count < items)
{
cout<<"Enter the value of the sales item. : $";
cin>>price;
total = total + price;
count ++;
}
cout<<"Enter in the sales tax percentage. :";
cin>>percent;
tax = (total/100.0)*percent;
g_t = tax + total;
cout << "***************************************" << endl;
cout << "***** Sales Receipt *****" << endl;
cout << "***************************************" << endl;
cout << "Total Sales: $"<<total<< endl;
cout << "Sales Tax: $"<<tax<< endl;
cout << "Total: $"<<g_t<<endl;
cout<<"Do you want to run that again (y/n)";
cin>>rerun;
}
while (rerun == 'y' || rerun == 'Y');
}
my only question is that when/if the user enters yes (to rerun the program) it skips the initial while loop (the prices loop) and goes straight to asking for the sales tax and i cant seem to understand why
wanna give me a push in the right direction? ive googled it and searched through my book and cant find information on resetting the counter, i think i remember doing it once for a program but cant recollect, not asking for a handout, just a shove.