I need help rerunning the program from the very beginning and I can't figure out what I am doing wrong...
Code:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
// 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;
// Input information
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 << 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');
return 0;
} //End Main Function
I've managed to look back but I need it to loop back to the beginning where it asks to input the number of items again.
In addition, I want to be able to display the sales items and their prices in the sales receipt as well.
Really appreciate the help! THANKS!