You are maintaining an inventory for a bookstore. You need a system that will le
ID: 3718842 • Letter: Y
Question
You are maintaining an inventory for a bookstore.
You need a system that will let you enter your inventory (and store it in a file). You also should be able to sort it, and update it. For the items in your inventory, you will be keeping track of its basic information (i.e. for books: name, publisher, year, author, pages, price).
Your system will allow you to keep track of who purchases the items from your store (name, address, telephone, what they bought, how much they paid). This information is also to be stored in a file (separate from the inventory file).
Your program should open with a menu that allows me to see your inventory (provide at least 3 ways of looking at your inventory - unsorted, and 2 sorted views - the sorted views are up to you). You could use a sorted view for the bookstore such as sorted by title or author, for example.
Your program should search your inventory by title, author, and year
Your program should 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 any 3 methods (of your choice - for example, by name, city, and phone).
Finally, I should be able to delete inventory or customers as well.
Your program should may consist of more than 1 .c file. For example, you could group your inventory functions into one .c file, and then your customer functions into another.
Your information should be read from files at the start of your program and stored into lists (arrays or linked lists - your choice). When the program ends, you write that data back out. While the program is running, you should of course write out any changes made to data; that way, if the program crashes you will not have lost all the changes made before the crash. Of course, if you make your program fault tolerant, crashes won't occur that often.
Explanation / Answer
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;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.