There is nothing in your code that would make it loop to ask for more products. You have this code:
Code:
cin >> ProdNum;
if (ProdNum!=0) {
cin >> ProdNum;
}
else {
cout<<"Thanks for shopping, your receipt is printed below" << endl << endl;
}
As you can see, if you enter in anything but 0 the first time, it asks you again, then just continues down to the end. What you want is something like this:
Code:
#include <iostream>
#include <fstream>
#include <cctype>
#include <string>
//#include "grocery.h"
using namespace std;
int ProdNum;
string ProdName;
float ProdPrice;
char Taxable;
int Quantity;
const int tax_rate=.075;
int main()
{
ifstream OpenFile("inventory.txt");
char ch;
while(!OpenFile.eof())
{
OpenFile.get(ch);
cout << ch;
}
cout << endl << endl;
cout << "Thanks for shopping at OUR Market." << endl << endl;
int customer = 1;
cout << "Enter purchases for customer " << customer++ << endl;
cout << "Enter product code 0 to end purchases." << endl << endl;
do
{
cin << ProdNum;
} while (ProdNum!=0); //loops while the user enters non-zero
cout<<"Thanks for shopping, your receipt is printed below" << endl << endl;
//Calculations
/*cout << "Is there another customer? (Y/N) ";
cin >> customer;
while (customer == "Y");
if (customer == "N")
cout << "Thanks for shopping at OUR Market." << endl;
*/
return 0;
}
You're also going to need to implement an array for the product entering part. I mean, the way it is now, you're only storing one Product Number. Each time the user enters a number, it overwrites the last one entered. I'll leave that to you however.