Question

Book-Shop management system C++ Create class book that contains attributes for book. Customer can search any...

Book-Shop management system C++
Create class book that contains attributes for book.

Customer can search any book by author or title, view the desired book and buy the book.
Staff can manage stock inventory, sales for any book and give discount to certain book.

The system can generate report for the sales and inventory.

Note: Important

use 2 and above classes ..!

Data Structure : Queue

Technique used :

  • Sorting and searching
  • main() program will declare a array of class and read information about the instance from a data file
  • implement all member functions through the element of the array
0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include<iostream> #include<string.h> #include<stdlib.h> using namespace std; class book        { private:      char *author,*title,*publisher;         float *price;   int *stock; public:             book()  {       author= new char[20];   title=new char[20];     publisher=new char[20];         price= new float;       stock=new int;  }       void feeddata();        void editdata();        void showdata();        int search(char[],char[]);      void buybook();          }; void book::feeddata()       {       cin.ignore();   cout<<"\nEnter Author Name: "; cin.getline(author,20);    cout<<"Enter Title Name: "; cin.getline(title,20);        cout<<"Enter Publisher Name: "; cin.getline(publisher,20);        cout<<"Enter Price: "; cin>>*price;         cout<<"Enter Stock Position: "; cin>>*stock;         } void book::editdata()        {               cout<<"\nEnter Author Name: "; cin.getline(author,20);    cout<<"Enter Title Name: "; cin.getline(title,20);        cout<<"Enter Publisher Name: "; cin.getline(publisher,20);        cout<<"Enter Price: "; cin>>*price;         cout<<"Enter Stock Position: "; cin>>*stock;         } void book::showdata()        {       cout<<"\nAuthor Name: "<<author;    cout<<"\nTitle Name: "<<title;      cout<<"\nPublisher Name: "<<publisher;      cout<<"\nPrice: "<<*price;  cout<<"\nStock Position: "<<*stock;          } int book::search(char tbuy[20],char abuy[20] )       {       if(strcmp(tbuy,title)==0 && strcmp(abuy,author)==0)             return 1;       else return 0;           } void book::buybook() {       int count;      cout<<"\nEnter Number Of Books to buy: ";         cin>>count;       if(count<=*stock)    {               *stock=*stock-count;            cout<<"\nBooks Bought Sucessfully";               cout<<"\nAmount: Rs. "<<(*price)*count;     }       else            cout<<"\nRequired Copies not in Stock"; } int main()      {       book *B[20];    int i=0,r,t,choice;     char titlebuy[20],authorbuy[20];        while(1)        {               cout<<"\n\n\t\tMENU"              <<"\n1. Entry of New Book"                <<"\n2. Buy Book"                 <<"\n3. Search For Book"          <<"\n4. Edit Details Of Book"             <<"\n5. Exit"             <<"\n\nEnter your Choice: ";              cin>>choice;                              switch(choice)  {                       case 1: B[i] = new book;                                B[i]->feeddata();                            i++;    break;                                                  case 2: cin.ignore();                           cout<<"\nEnter Title Of Book: "; cin.getline(titlebuy,20);                                cout<<"Enter Author Of Book: "; cin.getline(authorbuy,20);                                for(t=0;t<i;t++)     {                                       if(B[t]->search(titlebuy,authorbuy)) {                                               B[t]->buybook();                                             break;                                  }                               }                               if(t==1)                                cout<<"\nThis Book is Not in Stock";                                                              break;                  case 3: cin.ignore();                           cout<<"\nEnter Title Of Book: "; cin.getline(titlebuy,20);                                cout<<"Enter Author Of Book: "; cin.getline(authorbuy,20);                                                                for(t=0;t<i;t++)     {                                       if(B[t]->search(titlebuy,authorbuy)) {                                               cout<<"\nBook Found Successfully";                                                B[t]->showdata();                                            break;                                  }                               }                               if(t==i)                                cout<<"\nThis Book is Not in Stock";                              break;                                          case 4: cin.ignore();                           cout<<"\nEnter Title Of Book: "; cin.getline(titlebuy,20);                                cout<<"Enter Author Of Book: "; cin.getline(authorbuy,20);                                                                for(t=0;t<i;t++)     {                                       if(B[t]->search(titlebuy,authorbuy)) {                                               cout<<"\nBook Found Successfully";                                                B[t]->editdata();                                            break;                                  }                               }                               if(t==i)                                cout<<"\nThis Book is Not in Stock";                              break;                                          case 5: exit(0);                        default: cout<<"\nInvalid Choice Entered";                                        }       }                                       return 0; } 

Run Debug Stop Share Save MENU 1. Entry of New Book 2. Buy Book 3. Search For Book 4. Edit Details of Book 5. Exit Enter your

Run Debug Stop Share H MENU 1. Entry of New Book 2. Buy Book 3. Search For Book 4. Edit Details of Book 5. Exit Enter your ch

Debug Stop Silale MENU 1. Entry of New Book 2. Buy Book 3. Search For Book 4. Edit Details of Book 5. Exit Enter your choice:

Add a comment
Know the answer?
Add Answer to:
Book-Shop management system C++ Create class book that contains attributes for book. Customer can search any...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create an Item class, which is the abstract super class of all Items.           Item class...

    Create an Item class, which is the abstract super class of all Items.           Item class includes an attribute, description of type String for every item. [for eg. Book]                                                             A constructor to initialize its data member of Item class.               Override toString() method to return details about the Item class. Create the ExtraCharge interface with the following details.                       Declare a constant RATE with value 0.25   Declare a method called calculateExtraCharge(), which returns a double value. Create the...

  • c ++ Create a class Book with the data members listed below.     title, which is...

    c ++ Create a class Book with the data members listed below.     title, which is a string (initialize to empty string)     sales, which is a floating point value (as a double, initialize to 0.0) Include the following member functions:     Include a default constructor,     a constructor with parameters for each data member (in the order given above),     getters and setter methods for each data member named in camel-case. For example, if a class had a data...

  • C++ project we need to create a class for Book and Warehouse using Book.h and Warehouse.h header ...

    C++ project we need to create a class for Book and Warehouse using Book.h and Warehouse.h header files given. Then make a main program using Book and Warehouse to read data from book.dat and have functions to list and find book by isbn Objectives: Class Association and operator overloading This project is a continuation from Project 1. The program should accept the same input data file and support the same list and find operations. You will change the implementation of...

  • please Code in c++ Create a new Library class. You will need both a header file...

    please Code in c++ Create a new Library class. You will need both a header file and a source file for this class. The class will contain two data members: an array of Book objects the current number of books in the array Since the book array is moving from the main.cc file, you will also move the constant array size definition (MAX_ARR_SIZE) into the Library header file. Write the following functions for the Library class: a constructor that initializes...

  • MUST BE WRITTEN IN C++ Objective: Learn how to define structures and classes, create and access...

    MUST BE WRITTEN IN C++ Objective: Learn how to define structures and classes, create and access a vector of structures, use sort with different compare functions. Assignment: Your program will use the same input file, but you will print the whole book information, not just the title. And, most importantly, this time you will take an object oriented approach to this problem. Detailed specifications: Define a class named Collection, in which you will define a structure that can hold book...

  • MUST BE WRITTEN IN C++ Objective: Learn how to define structures and classes, create and access...

    MUST BE WRITTEN IN C++ Objective: Learn how to define structures and classes, create and access a vector of structures, use sort with different compare functions. Assignment: Your program will use the same input file, but you will print the whole book information, not just the title. And, most importantly, this time you will take an object oriented approach to this problem. Detailed specifications: Define a class named Collection, in which you will define a structure that can hold book...

  • About Classes and OOP in C++ Part 1 Task 1: Create a class called Person, which...

    About Classes and OOP in C++ Part 1 Task 1: Create a class called Person, which has private data members for name, age, gender, and height. You MUST use this pointer when any of the member functions are using the member variables. Implement a constructor that initializes the strings with an empty string, characters with a null character and the numbers with zero. Create getters and setters for each member variable. Ensure that you identify correctly which member functions should...

  • C++ In this homework, you will implement a single linked list to store a list of computer science textbooks. Ever...

    C++ In this homework, you will implement a single linked list to store a list of computer science textbooks. Every book has a title, author, and an ISBN number. You will create 2 classes: Textbook and Library. Textbook class should have all above attributes and also a "next" pointer. Textbook Туре String String String Attribute title author ISBN Textbook* next Library class should have a head node as an attribute to keep the list of the books. Also, following member...

  • Car Rental Management System The aim of this project is to design and implement a computerized...

    Car Rental Management System The aim of this project is to design and implement a computerized Car Rental Management System for a company called COEN244Cars. The company rents two types of cars: standard and luxury cars. A car is identified by a car identification number (int), a type (string), and a flag that indicates whether the car is currently available or not. The company distinguishes between three types of customers: regular customers, corporate customers, and VIPs (Very Important Persons). A...

  • The file Sorting.java contains the Sorting class from Listing 9.9 in the text. This class implements...

    The file Sorting.java contains the Sorting class from Listing 9.9 in the text. This class implements both the selection sort and the insertion sort algorithms for sorting any array of Comparable objects in ascending order. In this exercise, you will use the Sorting class to sort several different types of objects. 1. The file Numbers.java reads in an array of integers, invokes the selection sort algorithm to sort them, and then prints the sorted array. Save Sorting.java and Numbers.java to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT