Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C program inventory for a bookstore. I need a system that will let you enter you

ID: 3917026 • Letter: C

Question

C program inventory for a bookstore.

I need a system that will let you enter your inventory and store it in a file. I also should be able to sort it, and update it. For the items in the inventory, I will be keeping track of its information (name, publisher, year, author, pages, price).

The system will allow you to keep track of who purchases the items from the store (name, address, telephone, what they bought, how much they paid). This information should also to be stored in a file that is seperate from the inventory file.

The program should open with a menu that allows me to see the inventory (provide at least 3 ways of looking at the inventory - unsorted, and 2 sorted views by title and author.

The program should let me search the inventory by 1- author, 2- year and 3-title.

The program should also let me then enter a customer's data and what they bought. I should then also be able to see the list of customer's (sorted and unsorted) and also search the customer list based upon city phone and their name.

I should also be able to delete inventory and customers.

IMPORTANT TO USE

C using stdio.h

Example output

Explanation / Answer

PROGRAM CODING:

#include<fstream>
#include<string.h>
#include<conio.h>
#include<iomanip>
#include<dos.h>
#include<iostream>
#include <stdlib.h>
#include<windows.h>

using namespace std;

class BookShop
{
public:

char book_Code[10],book_Name[20],writer_Name[20];
float cost;

void get_data()
{
cout<<" Enter Name of Book :";
cin>>book_Name;

cout<<" Enter Book's Code : ";
cin>>book_Code;

cout<<" Enter Writers Name :";
cin>>writer_Name;

cout<<" Enter Book's Cost :";
cin>>cost;
cout<<endl;
};

};


class book_bookFiles:public BookShop
{
public:
addBooks()
{
fstream bookFiles("EntireBook.txt",ios::out|ios::app);

bookFiles.width(20);
bookFiles<<setiosflags(ios::left);
bookFiles<<book_Name;

bookFiles.width(20);
bookFiles<<setiosflags(ios::left);
bookFiles<<writer_Name;

bookFiles.width(10);
bookFiles<<setiosflags(ios::right);
bookFiles<<book_Code;

bookFiles.width(10);
bookFiles<<setiosflags(ios::right);
bookFiles<<cost<<endl;

bookFiles.close();
}
void bookFiles();

};
void book_bookFiles::bookFiles()
{
char fil[20];

get_data();
strcpy(fil,book_Code);
strcat(fil,".txt");

ofstream bookFiles(fil);
bookFiles<<"Book Name :"<<book_Name<<endl;
bookFiles<<"Writer Name :"<<writer_Name<<endl;
bookFiles<<"Book book_Code :"<<book_Code<<endl;
bookFiles<<"cost :"<<cost<<endl;
bookFiles.close();

}


class Type1:public book_bookFiles
{
public:

void book_Record()
{
fstream b1_bookFiles("Fiction.txt",ios::out|ios::app);
b1_bookFiles<<endl;
b1_bookFiles<<"Book's Name :"<<book_Name<<endl;
b1_bookFiles<<"Writer's Name :"<<writer_Name<<endl;
b1_bookFiles<<"Book's Code :"<<book_Code<<endl;
b1_bookFiles<<"Book's Price :"<<cost<<endl;
b1_bookFiles.close();
}
};


class Type2:public book_bookFiles
{
public:

void book_Record()
{
fstream b1_bookFiles("History.txt",ios::out|ios::app);
b1_bookFiles<<endl;
b1_bookFiles<<"Book Name :"<<book_Name<<endl;
b1_bookFiles<<"Writer Name :"<<writer_Name<<endl;
b1_bookFiles<<"Book book_Code :"<<book_Code<<endl;
b1_bookFiles<<"cost :"<<cost<<endl;
b1_bookFiles.close();
}
};

class Type3:public book_bookFiles
{
public:

void book_Record()
{
fstream b1_bookFiles("Physics.txt",ios::out|ios::app);
b1_bookFiles<<endl;
b1_bookFiles<<"Book Name :"<<book_Name<<endl;
b1_bookFiles<<"Writer Name :"<<writer_Name<<endl;
b1_bookFiles<<"Book book_Code :"<<book_Code<<endl;
b1_bookFiles<<"cost :"<<cost<<endl;
b1_bookFiles.close();
}
};

class Type4:public book_bookFiles
{
public:

void book_Record()
{
fstream b1_bookFiles("Computer.txt",ios::out|ios::app);
b1_bookFiles<<endl;
b1_bookFiles<<"Book Name :"<<book_Name<<endl;
b1_bookFiles<<"Writer Name :"<<writer_Name<<endl;
b1_bookFiles<<"Book book_Code :"<<book_Code<<endl;
b1_bookFiles<<"cost :"<<cost<<endl;
b1_bookFiles.close();
}
}; //Type4 class ends


class AddToRecords
{
public:
AddToRecords();
};

AddToRecords::AddToRecords()

{

Type1 Type1;
Type2 Type2;
Type3 Type3;
Type4 Type4;
int option;

while(1)
{
system("cls");
cout<<"....................Add Books to Inventory................";
cout<<" 1.Fiction Books 2.History books 3.Physics Books 4.Computer books 5.Exit ";
cout<<" option:";
cin>>option;

if(option==1)
{
Type1.bookFiles();
Type1.book_Record();
Type1.addBooks();

}

if(option==2)
{
Type2.bookFiles();
Type2.book_Record();
Type2.addBooks();

}

if(option==3)
{
Type3.bookFiles();
Type3.book_Record();
Type3.addBooks();

}

if(option==4)
{
Type4.bookFiles();
Type4.book_Record();
Type4.addBooks();

}

if(option==5)
{
break;
}

}   

}


class show
{
public:
show();
};


show::show()
{
int option;
char book_Code[10],ch;
while(1)
{
cout<<" ...................Display Inventory..................... ";
cout<<"1.All Books"<<endl;
cout<<"2.Fiction"<<endl;
cout<<"3.History"<<endl;
cout<<"4.Physics"<<endl;
cout<<"5.Computer"<<endl;
cout<<"6.Exit"<<endl;

//...................................................................
cout<<" WELCOME TO ALL NEW BOOK STORE Enter Ur option:" ;
cin>>option;

if(option==1)
{
system("cls");

cout<<endl;
cout.width(20);
cout<<setiosflags(ios::left);
cout<<"Book Name";

cout.width(20);
cout<<setiosflags(ios::left);
cout<<"Writer Name";

cout.width(10);
cout<<setiosflags(ios::right);
cout<<"book_Code";

cout.width(10);
cout<<setiosflags(ios::right);
cout<<"cost"<<endl<<endl;

fstream bookFiles("EntireBook.txt",ios::in);
bookFiles.seekg(0);
while(bookFiles)
{
bookFiles.get(ch);
cout<<ch;
}
bookFiles.close();
getch();
}

if(option==2)
{
system("cls");
fstream bookFiles("Fiction.txt",ios::in);
bookFiles.seekg(0);
cout<<" ";
while(bookFiles)
{
bookFiles.get(ch);
Sleep(10);
cout<<ch;
}
bookFiles.close();
getch();
}

if(option==3)
{
system("cls");
fstream bookFiles("History.txt",ios::in);
bookFiles.seekg(0);
cout<<" ";
while(bookFiles)
{
bookFiles.get(ch);
Sleep(10);
cout<<ch;
}
bookFiles.close();
getch();
}

if(option==4)
{
system("cls");
fstream bookFiles("Physics.txt",ios::in);
bookFiles.seekg(0);
cout<<" ";
while(bookFiles)
{
bookFiles.get(ch);
Sleep(10);
cout<<ch;
}
bookFiles.close();
getch();
}

if(option==5)
{
system("cls");
fstream bookFiles("d:\Computer.txt",ios::in);
bookFiles.seekg(0);
cout<<" ";
while(bookFiles)
{
bookFiles.get(ch);
Sleep(10);
cout<<ch;
}
bookFiles.close();
getch();
}

if(option==6)
break;

}   
}


class search
{
public:
search();
};

search::search()
{
int option;
char fil[20];
char ch,book_Code[10];
while(1)
{
system("cls");
cout<<" ....................SEARCH Inventory................... ";
cout<<"1.Search";
cout<<" 2.Exit ";
cout<<" Chioce:";
cin>>option;
if(option==1)
{
cout<<"Enter book_Code:";
cin>>book_Code;
cout<<endl;
strcpy(fil,book_Code);
strcat(fil,".txt");
fstream bookFiles(fil,ios::in);
while(bookFiles)
{
bookFiles.get(ch);
cout<<ch;
}
bookFiles.close();
getch();
}
if(option==2)
break;
}


}

class start
{
public:
start();
};

start::start()
{
int option;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 12);
  
while(1)
{
system("cls");
cout<<" .........Enter Your option........ ";
cout<<"1.Add to Inventory ";
cout<<"2.View Inventory ";
cout<<"3.Search Inventory ";
cout<<"4.Exit ";
cout<<"Enter option:";
cin>>option;

if(option==1)
{ AddToRecords a;}

if(option==2)
{ show d;}

if(option==3)
{search s; }

if(option==4)
{
   cout<<":)";
break;
   }  
}

  

}   


int main()
{
start end;
return 0;
}