Question: Please fix the errors and finish coding this. C++ was used TOPIC: Supermarket Inventory and Billing System #include #include #include #include #include #include #include #include

Please fix the errors and finish coding this. C++ was used

TOPIC: Supermarket Inventory and Billing System

#include #include #include #include #include #include #include #include #include

using namespace std;

fstream file;

void time() { time_t tim; //create variable time(&tim); //pass variable to time function cout<

void printlines() //for printing the stars as shown { cout<<" _________________________________________________________________________________________________________ "<

void display() { cout<

}

//****************************************************************************//

//***************Class User***************// class user { private: char username[20]; char password[20]; public: void add_user() { cout<<" \t\t\tADD USER "; cout<<" \t\tEnter username and password "; cout<<"\tUsername: "; cin>>username; cout<<"\tPassword: "; cin>>password; file.open("user.txt",ios::app|ios::out); file.write(reinterpret_cast(this),sizeof(*this)); file.close(); } int verify() { display(); char u[20]; char pw[20]; int count; cout<<" \t\tPlease enter username and password "; cout<<"\tUsername: "; cin>>u; cout<<"\tPassword: "; cin>>pw; file.open("user.txt",ios::in); file.seekg(0); file.read(reinterpret_cast(this),sizeof(*this)); while(!file.eof()) { if(strcmp(username,u)==0)) { if(strcmp(password,pw)==0)) { count=1; } } file.read(reinterpret_cast(this),sizeof(*this)); } file.close(); return(count); } }; //***************Class Customer***************// class customer { private: char fname[20],lname[20]; char add[25]; char cn[10]; public: void c_read(); void c_display(); };

void customer::c_read() { display(); cout<<"Enter the full name of the customer: "; cin>>fname; cin>>lname; cout<<"Enter the address of the customer: "; cin>>add; cout<<"Enter the contact number of the customer: "; cin>>cn; } void customer::c_display() { cout<<"Name: "<

//***************Class Product***************//

class product : public user { protected: unsigned int id; char name[50]; float rate; float dis; public: void create_product(); void show_product(); void display_all(); void display_sp(); void price_list(); void modify_product(); void delete_product(); void fread() { file.read(reinterpret_cast(this),sizeof(*this)); } void admin_menu(); };

void product::create_product() { cout<<" Enter the product ID: "; cin>>id; cout<<" Enter the product name: "; cin>>name; cout<<" Enter the product rate: "; cin>>rate; cout<<" Enter the discount (%): "; cin>>dis; file.open("product.dat",ios::app|ios::out); file.write(reinterpret_cast(this),sizeof(*this)); file.close(); cout<<" The product has been created."; }

void product::show_product() { cout<<"**************************************"; cout<<" Product ID: "<

void product::display_all() { cout<<" \t\tDISPLAYING RECORD "; file.open("product.dat",ios::in); file.seekg(0); file.read(reinterpret_cast(this),sizeof(*this)); while(!file.eof()) { show_product(); file.read(reinterpret_cast(this),sizeof(*this)); cout<<" -------------------------------------- "; } file.close(); getch(); }

void product::display_sp() { int n,flag=0; cout<<"Enter the product ID of the product to be displayed: "; cin>>n; file.open("product.dat",ios::in); file.seekg(0); while(!file.eof()) { file.read(reinterpret_cast(this),sizeof(*this)); if(id==n) { system("cls"); show_product(); flag=1; } } file.close(); if(flag==0) cout<<" Record does not exist."; getch(); }

void product::price_list() { file.open("product.dat",ios::in); cout<<"=================================================== "; cout<<"\t\t\t\tPRODUCT MENU "; cout<<"=================================================== "; cout<<"Product ID\t\tNAME\t\tPRICE "; file.seekg(0); file.read(reinterpret_cast(this),sizeof(*this)); while(!file.eof()) { cout<(this),sizeof(*this)); } file.close(); getch(); }

void product::modify_product() { int n,pos,flag=0; cout<<" Enter the product ID of the product to be modified: "; cin>>n; file.open("product.dat",ios::in|ios::out); while(!file.eof()) { file.read(reinterpret_cast(this),sizeof(*this)); if(id==n) { show_product(); pos=-1*sizeof(*this); file.seekp(pos,ios::cur); cout<<" Enter the product ID: "; cin>>id; cout<<" Enter the product name: "; cin>>name; cout<<" Enter the product rate: "; cin>>rate; cout<<" Enter the discount (%): "; cin>>dis; file.write(reinterpret_cast(this),sizeof(*this)); cout<<" \t Record updated."; flag=1; } } file.close(); if(flag==0) cout<<" Record not found!"; getch(); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!