I want to have the ability to rerun the following from the very beginning, however, I have only been able to get it to rerun from the middle of the program where it asks for sales tax. I've tried moving my do/while tags around to everywhere but nothing seems to work whatsoever. Would really appreciate the help.
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
do //The do-while for a program rerun option
{
// Declare variables: counter, items, sales items, sales total, sales tax, and grand total
float items = 0;
float count = 0;
float price = 0;
float total = 0;
float percent;
float g_t;
float tax;
char rerun;
while (count < items)
{
// Input information
cout<<"How many sales items do you have? :";
cin>>items;
cout<<"Enter the value of the sales item. : $";
cin>>price;
total = total + price;
count ++;
cout << endl << endl;
cout<<"Enter in the sales tax percentage. :";
cin>>percent;
tax = total * (percent/100);
g_t = tax + total;
cout << endl << endl;
cout << "********************************************" << endl;
cout << "******** S A L E S R E C E I P T ********" << endl;
cout << "********************************************" << endl;
cout << "** **" << endl;
cout << "** **" << endl;
cout << "** **" << endl;
cout << "** **" << endl;
cout << setiosflags(ios::fixed) << setprecision(2);
cout << "** Total Sales: $" << setw(9) << total << " **" << endl;
cout << "** Sales Tax: $" << setw(9) << tax << " **" << endl;
cout << "** ----------- **" << endl;
cout << "** Grand Total: $" << setw(9) << g_t << " **" << endl;
cout << "** **" << endl;
cout << "** **" << endl;
cout << "********************************************" << endl;
cout << endl << endl;
cout<<"Do you want to run this program again? (y/n)";
cin>>rerun;
}
}
while (rerun == 'y' || rerun == 'Y');
} //End Main Function
The code above currently gives me an undeclared identifier error.
Thanks in advance!