#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;
int main()
{
string saveload;
int numProducts=0;
int counter=1;
int product;
double payment1;
double change=0;
double subtotal=0;
double payment=0;
int n;
string Id;
int option;
const char* products[] = {"Cardinal Steak w/ drink and dessert", "Cardinal Grilled Chicken w/ drink and dessert",
"Cardinal Bangus w/ drink and dessert", "Mathematician Burger w/ drink and dessert",
"Cardinal Spring Rolls w/ drink and dessert", "Cardinal Steak", "Cardinal Grilled Chicken", "Cardinal Bangus",
"Mathematician Burger", "Cardinal Spring Rolls", "Sweet Mapuan Potato", "Wedged Mapuan Potato",
"Mashed Math Potato w/ gravy", "Physics Special Salad", "Chemistry Hot wings Special", "Sinko Shake",
"Banofee", "Korean shaved ice with sugar, fruit syrup", "Nigerian Pepper Soup", "Sudanese Basbosa"};
double prices[] = {450, 400, 200, 250, 350, 300, 280, 140, 130, 150, 80, 90, 60, 40, 100, 55, 60, 77, 77, 85};
int items[100];
cout<<setw(120)<<"Organic Food Chain"<<endl;
cout<<"Please enter your Id"<<endl;
cout<<"Id: ";
cin>>Id;
if(Id=="a")
{
cout<<"Password: *******"<<endl<<endl;
cout<<"1. Order"<<endl;
cout<<"2. Show the record"<<endl;
cout<<"3. Log out"<<endl;
cout<<"Choose: ";
cin>>option;
cout<<endl;
if(option==1)
{
cout<<"How many products are you ordering?: ";
cin>>numProducts;
for(n = 0;n<numProducts;n++)
{
cout<<"Combo"<<endl;
cout<<"1.Cardinal Steak w/ drink and dessert Php450"<<endl;
cout<<"2.Cardinal Grilled Chicken w/ drink and dessert Php400"<<endl;
cout<<"3.Cardinal Bangus w/ drink and dessert Php200"<<endl;
cout<<"4.Mathematician Burger w/ drink and dessert Php250"<<endl;
cout<<"5.Cardinal Spring Rolls w/ drink and dessert Php350"<<endl<<endl;
cout<<"Alacarte"<<endl;
cout<<"6.Cardinal Steak Php300"<<endl;
cout<<"7.Cardinal Grilled Chicken Php280"<<endl;
cout<<"8.Cardinal Bangus Php140"<<endl;
cout<<"9.Mathematician Burger Php130"<<endl;
cout<<"10.Cardinal Spring Rolls Php150"<<endl<<endl;
cout<<"Sidedish"<<endl;
cout<<"11.Sweet Mapuan Potato Php80"<<endl;
cout<<"12.Wedged Mapuan Potato Php90"<<endl;
cout<<"13.Mashed Math Potato w/ gravy Php60"<<endl;
cout<<"14.Physics Special Salad Php40"<<endl;
cout<<"15.Chemistry Hot wings Special Php100"<<endl<<endl;
cout<<"Drink & Dessert"<<endl;
cout<<"16.Sinko Shake Php55"<<endl;
cout<<"17.Banofee Php60"<<endl;
cout<<"18.Korean shaved ice with sugar, fruit syrup Php77"<<endl;
cout<<"19.Nigerian Pepper Soup Php77"<<endl;
cout<<"20.Sudanese Basbosa Php85"<<endl;
do{
cout <<"Enter your selection: ";
cin>>product;
cout<<endl;
}while(product < 1 || product > 20);
items[n]=product-1;
}
subtotal=0;
for(n=0;n<numProducts;n++)
{
cout<<left<<setw(25)<<products[items[n]];
cout<<right<<setw(10)<<prices[items[n]]<<endl;
subtotal=subtotal+prices[items[n]];
}
cout<<right;
cout<<"-----------------------------------------"<<endl;
cout<<"Total: "<<setw(24)<<subtotal<<endl;
do{
cout<<"Please make payment: ";
cin>>payment1;
payment=payment+payment1;
if(payment > subtotal)
{
change=payment-subtotal;
cout<<"Your change is: "<<change;
ofstream out("save.txt");
cout.rdbuf(out.rdbuf());
cout<<left<<setw(25)<<products[items[n]];
cout<<right<<setw(10)<<prices[items[n]]<<endl;
subtotal=subtotal+prices[items[n]];
cout<<right;
cout<<"-----------------------------------------"<<endl;
cout<<"Total: "<<setw(24)<<subtotal<<endl;
cout<<"Please make payment: "<<payment;
cout<<"Your change is: "<<change;
}
}while((payment-subtotal) < 0);
}
if(option==2);
}
else
{
cout<<"Please enter the correct Id";
}
return 0;
}
I made the first few sentences but inside if statements I just followed one of the POS program in the net. The problem is that I have to save and load the record but I can not save it. The part that Im going to save is where the code ofstream out("save.txt"); cout.rdbuf(out.rdbuf()); You can totally erase this statement as long as I can save those information. For additional can you add there how to load?? Though it is not complete yet, I just need to know how to save and load the record in this program. please help. Thank you very much. By the way I am using Dev C++ ver.5.5.1.