software for supermarket

I'm a beginner to C++ and writing a point of sale software for supermarket.
I used if....else statements. If for the shop owner and else for salespersonel. Since the salespersonel will be using it continously, i want my program to redisplay the salespersonel screen after inputing data and printing receipt for the customer. I hope to hear from you good friends.



I also want the program to store prices of goods entered by the store owner so the salesperson (the program) can use this information later to calculate cost of goods to customers and then the stored information is always updated as and when the salesperson use the program. Counting on your numerous support.

3. I want to know how to set password for the shop owner and the salesperson in the program.

This is my coding

int main()
{
using namespace std;

string name, ict;
int numOfMilk, milkBox;
int numOfSardine, sardineBox;
int numOfMilo, miloBox;
int numOfCerelac, cerelacBox;
int numOfIndomie, indomieBox;
int numOfBoxes, milk, sardine, milo, cerelac, indomie;
int totalNumOfBoxesBought;
int totalNumOfBoxesSold;
int counter;
double costOfOneBox,totalPrice, eachMilkPrice, eachSardinePrice, ;
double eachCerelacPrice, eachMiloPrice, eachIndomiePrice;
char filename[] = "shopitems.txt";

cout << fixed << showpoint << setprecision(2);


totalNumOfBoxesBought = 0;
totalPrice = 0;
counter = 0;

cout << "Enter your password: ";
cin >> ict;
cout << endl;

if (ict == "Admin")
{
while (counter < 5)
{
cout << "Enter the items name,"
<< " the number of boxes bought and cost of each box: " << endl;
cin >> name >> numOfBoxes >> costOfOneBox;

cout << endl;

totalNumOfBoxesBought = totalNumOfBoxesBought
+ numOfBoxes;
totalPrice = totalPrice + costOfOneBox;
ofstream fout(filename);
fout << name << "," << numOfBoxes << "," << costOfOneBox << "\n";
fout.close();
counter++;
}
cout << "Total number of boxes bought = "<< totalNumOfBoxesBought << endl;
cout << "Total price of boxes bought = Ghc "<< totalPrice << endl << endl;

cout << "Enter the price of each milk." << endl;
cin >> eachMilkPrice;
cout << endl;

cout << "Enter the price of each sardine." << endl;
cin >> eachSardinePrice;
cout << endl;

cout << "Enter the price of each milo." << endl;
cin >> eachMiloPrice;
cout << endl;

cout << "Enter the price of each cerelac." << endl;
cin >> eachCerelacPrice;
cout << endl;

cout << "Enter the price of each indomie." << endl;
cin >> eachIndomiePrice;
cout << endl;
}

else
if (ict == "salesperson")
{
//Salesperson area
cout << "Enter number of milk sold: ";
cin >> milk;
cout << endl;
cout << "Enter number of sardine sold: ";
cin >> sardine;
cout << endl;
cout << "Enter number of milo sold: ";
cin >> milo;
cout << endl;
cout << "Enter number of cerelac sold: ";
cin >> cerelac;
cout << endl;
cout << "Enter number of indomie sold: ";
cin >> indomie;
cout << endl << endl;

cout << "\tGroup 27 Supermarket\n" << "\t PMB G27, Winneba" << endl;
cout << " Contact: 5121570025, 5121570057" << endl;
cout << "\t 5121570086, 5121570115.\n" << endl;
cout << " Items\t" << "\t\tPrice(Ghc)" << endl << endl;
cout << " Milk\t" << "\t\t" << milk*eachMilkPrice << endl;
cout << " Sardine" << "\t\t" << sardine * eachSardinePrice << endl;
cout << " Milo\t" << "\t\t" << milo * eachMiloPrice << endl;
cout << " Cerelac" << "\t\t" << cerelac * eachCerelacPrice << endl;
cout << " Indomie\t" << "\t" << indomie * eachIndomiePrice << endl;
cout << "\n Total price\t" << "\t" << ((eachMilkPrice*milk) + (eachSardinePrice*sardine)+
(eachMiloPrice*milo) + (eachCerelacPrice*cerelac) + (eachIndomiePrice*indomie)) << endl << endl;
cout << "\n\n\tGreat doing business with you\n";
cout << "\t\tThank you\!\!" << endl << endl;

}

system ("pause");
return 0;
}
Last edited on
1. you may put the else part in a while loop like:
1
2
while(1)
{................};


2. you must use/learn datafile handling for this

3. you can use if() for this e.g
1
2
3
4
5
std::string pswd="abcd";
if(pswd==enteredpswd)
{......execute program;}
else
{std::cout<<"wrong pswd";   exit(1);}
Pls, aalok i will need your help as i'm now into programming. Can i have your email or any contact so you can help me. i'm on whatsapp (+233268855434), facebook (adepa ampofo). i will be glad if any one help me to be a good programmer. Tanx
i'm on facebook as "aarajawat"

Topic archived. No new replies allowed.