Hello All,
I am writing a program to act as a cash register. I reads in from a file that looks like this:
A Cheeseburger 2.97
B Soda 1.90
C Sundae 3.50
...and so on.....
The point is for the user to enter a single letter and then the item and the price appear. The user should be able to keep ordering items until they hit the "=". Then the outer loop stops.
The 1st time through the loop, everything works fine, but after that, the inner loop doesnt work.
Any suggestions???
Thanks,
Jordan
int main()
{
time_t t;
time(&t);
yl;
cls;
string order;
stringstream ssprice;
double total= 0, pric;
int count = 0;
cout <<"J.Maniscalco 9827 Payroll3 " << ctime(&t) << endl << endl;
print <<"J.Maniscalco 9827 Payroll3 " << ctime(&t) << endl << endl;
while (! infile)
{
cout << "Error opening file " << endl;
exit(1);
}
while (order != "=")
{
cout << "Enter key" << endl;
cin >> order;
string info;
while (getline (infile, info))
{
string name = info;
string key, item, price;
key = name.substr(0,1);
item = name.substr(4,22);
price = name.substr(27,4);
if(key == order)
{
cout << item << price << endl;
}
}//end while
}
cout << total << endl;
frz;
return 0;
} // end of main function