Originally Posted by
tabstop
You have to close off your do curly-braces before you get to the while, not after.
When I do that, I get an undeclared identifier error...
Code:
// TipCalculator.cpp
// Neel Patel
// Homework4, Sales Receipt, Because it can calculate and print to the screen a user inputted sales receipt.
#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