book_inventry_system
book_inventry_system
#include <iostream>
#include <stdlib.h>
#include <cstring>
using namespace std;
class Book
{
char author[20];
char title [20];
char publisher[20];
double price;
int stock;
static int noTrans;
public:
void insertdata();
void display();
int search(char[],char[]);
void noCopies(int);
private:
void priceUpdate()
{
char update;
cout<<"Do you want to update the Book price [y/n] or [Y/N]: ";
cin>>update;
if(update=='y'||update=='Y')
{
cout<<"\nEnter the Price: ";
cin>>price;
}
else
{
cout<<"\nFixed Price will be charge.";
}
}
};
void screen();
void menu();
int main()
{
screen();
cout<<"\n";
system("COLOR 2F");
Book b[50];
char bookTitle[50];
char bookAuthor[50];
bool flag;
flag = false;
int ch, i, start = 0,numberOfBook, order;
do
{
menu();
cout<<"\nPlease Enter your choice: ";
cin>>ch;
switch(ch)
{
case 1:
cout<<"\nEnter the number of books you want to store: ";
cin>>numberOfBook;
for(i=0;i<numberOfBook;i++)
{
b[i].insertdata();
}
break;
case 2:
for(i=0;i<numberOfBook;i++)
{
cout<<endl;
b[i].display();
}
break;
case 3:
cout<<"Enter the book title: ";
cin>>bookTitle;
cout<<"Enter the book author: ";
cin>>bookAuthor;
for(i=0;i<numberOfBook;i++)
{
if(b[i].search(bookTitle,bookAuthor))
{
flag = true;
b[i].display();
start = i;
}
}
if(flag)
{
cout<<"\nThe book is Available";
}
else
{
cout<<"\nThis Book is not available";
break;
}
if(flag)
{
cout<<"\nHow many books you want to order: ";
cin>>order;
b[start].noCopies(order);
}
break;
case 4:
exit("EXIT_SUCCESS");
break;
default:
cout<<"\nWrong Choice !! Please Run the Programme Again";
}
}while(ch!=5);
return 0;
}
void Book::insertdata()
{
cout<<"Enter the Author's Name: ";
cin>>author;
cout<<"Enter the Title of the Book: ";
cin>>title;
cout<<"Enter the Publisher's Name: ";
cout<<"Enter the Book's Price: ";
cout<<"Enter the Stock position of the books: ";
cin>>stock;
}
void Book::display()
{
cout<<"\nBook Title: "<<title<<"\nBook Author: "<<author<<"\nPublisher: "<<publisher<<"\nPrice: "<<price<<"Rs"<<endl;
cout<<"Stock Position: "<<stock<<endl;
}
int Book::search(char T[],char A[])
{
if(strcmp(title,T)&& (strcmp(author,A)))
{
return 0;
}
else
{
return 0;
}
}
void Book::noCopies(int nc)
{
if(stock>=nc)
{
cout<<"\nThe Title and Author of the book is available.";
cout<<"\nThe cost of "<<nc<<" books is:Rs."<<(nc*price)<<endl;
}
else
{
cout<<"\nRequired copies not in the stock...."<<endl;
}
}
void screen()
{
for(int i=0; i<=79;i++)
cout<<char(219);
for(int i=0; i<=79;i++)
cout<<char(220);
cout<<"\n";
cout<<" "<<char(201)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)
<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(187)<<endl;
cout<<" "<<char(186)<<" BOOK INVENTORY "<<char(186)<<endl;
cout<<" "<<char(200)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)
<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(188)<<endl;
cout<<"\n";
for(int i=0; i<=79;i++)
cout<<char(219);
for(int i=0; i<=79;i++)
cout<<char(220);
cout<<"\n";
cout<<" "<<char(218)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)
<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(191)<<endl;
cout<<" "<<char(179)<<" BOOK STORE "<<char(179)<<endl;
cout<<" "<<char(192)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)
<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(217)<<endl;
for(int i=0; i<=79;i++)
cout<<char(220);
}
void menu()
{
cout<<"INSERT THE BOOKS DATA: 1\n";
cout<<"DISPLAY THE NO.BOOKS : 2\n";
cout<<"SEARCH THE NO.BOOKS : 3\n";
cout<<"EXIT THE SYSTEM : 4\n";
cout<<"END THE PROGRMME : 5\n";
}
#include <iostream>
#include <stdlib.h>
#include <cstring>
using namespace std;
class Book
{
char author[20];
char title [20];
char publisher[20];
double price;
int stock;
static int noTrans;
public:
void insertdata();
void display();
int search(char[],char[]);
void noCopies(int);
private:
void priceUpdate()
{
char update;
cout<<"Do you want to update the Book price [y/n] or [Y/N]: ";
cin>>update;
if(update=='y'||update=='Y')
{
cout<<"\nEnter the Price: ";
cin>>price;
}
else
{
cout<<"\nFixed Price will be charge.";
}
}
};
void screen();
void menu();
int main()
{
screen();
cout<<"\n";
system("COLOR 2F");
Book b[50];
char bookTitle[50];
char bookAuthor[50];
bool flag;
flag = false;
int ch, i, start = 0,numberOfBook, order;
do
{
menu();
cout<<"\nPlease Enter your choice: ";
cin>>ch;
switch(ch)
{
case 1:
cout<<"\nEnter the number of books you want to store: ";
cin>>numberOfBook;
for(i=0;i<numberOfBook;i++)
{
b[i].insertdata();
}
break;
case 2:
for(i=0;i<numberOfBook;i++)
{
cout<<endl;
b[i].display();
}
break;
case 3:
cout<<"Enter the book title: ";
cin>>bookTitle;
cout<<"Enter the book author: ";
cin>>bookAuthor;
for(i=0;i<numberOfBook;i++)
{
if(b[i].search(bookTitle,bookAuthor))
{
flag = true;
b[i].display();
start = i;
}
}
if(flag)
{
cout<<"\nThe book is Available";
}
else
{
cout<<"\nThis Book is not available";
break;
}
if(flag)
{
cout<<"\nHow many books you want to order: ";
cin>>order;
b[start].noCopies(order);
}
break;
case 4:
exit("EXIT_SUCCESS");
break;
default:
cout<<"\nWrong Choice !! Please Run the Programme Again";
}
}while(ch!=5);
return 0;
}
void Book::insertdata()
{
cout<<"Enter the Author's Name: ";
cin>>author;
cout<<"Enter the Title of the Book: ";
cin>>title;
cout<<"Enter the Publisher's Name: ";
cout<<"Enter the Book's Price: ";
cout<<"Enter the Stock position of the books: ";
cin>>stock;
}
void Book::display()
{
cout<<"\nBook Title: "<<title<<"\nBook Author: "<<author<<"\nPublisher: "<<publisher<<"\nPrice: "<<price<<"Rs"<<endl;
cout<<"Stock Position: "<<stock<<endl;
}
int Book::search(char T[],char A[])
{
if(strcmp(title,T)&& (strcmp(author,A)))
{
return 0;
}
else
{
return 0;
}
}
void Book::noCopies(int nc)
{
if(stock>=nc)
{
cout<<"\nThe Title and Author of the book is available.";
cout<<"\nThe cost of "<<nc<<" books is:Rs."<<(nc*price)<<endl;
}
else
{
cout<<"\nRequired copies not in the stock...."<<endl;
}
}
void screen()
{
for(int i=0; i<=79;i++)
cout<<char(219);
for(int i=0; i<=79;i++)
cout<<char(220);
cout<<"\n";
cout<<" "<<char(201)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)
<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(187)<<endl;
cout<<" "<<char(186)<<" BOOK INVENTORY "<<char(186)<<endl;
cout<<" "<<char(200)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)
<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(205)<<char(188)<<endl;
cout<<"\n";
for(int i=0; i<=79;i++)
cout<<char(219);
for(int i=0; i<=79;i++)
cout<<char(220);
cout<<"\n";
cout<<" "<<char(218)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)
<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(191)<<endl;
cout<<" "<<char(179)<<" BOOK STORE "<<char(179)<<endl;
cout<<" "<<char(192)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)
<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(217)<<endl;
for(int i=0; i<=79;i++)
cout<<char(220);
}
void menu()
{
cout<<"INSERT THE BOOKS DATA: 1\n";
cout<<"DISPLAY THE NO.BOOKS : 2\n";
cout<<"SEARCH THE NO.BOOKS : 3\n";
cout<<"EXIT THE SYSTEM : 4\n";
cout<<"END THE PROGRMME : 5\n";
}
No comments: