I need help with this program where i need to create a book record program where the program can view, update, add and delete books. Now this is the main menu:
MAIN MENU
0. Exit
1. Search for a book
2. List books of a category
3. List books in a price range
4. List all books
5. Update a book record
6. Add a book record
7. Delete a book record
Your choice ->
You may use system calls such as system(“cls”), system(“pause”) and system(“echo.”) to
help maintain the above user interface

So far i did upto choice 4 but the update, add and deleting the book i can't seem to be getting it right here's my code and also if possible could you help me put a proper inout check for option 1, 5, 6 and 7:

#include <iostream>
#include <string>
#include <iomanip>

using namespace std;


int main() 
{

    char choice;



    start: 
     cout << "::MAIN MENU:: " << endl;
     cout << "0. Exit" << endl;
     cout << "1. Search for a book" << endl;
     cout << "2. List books of a category" << endl;
     cout << "3. List books in a price range" << endl;
     cout << "4. List all books" << endl;
     cout << "5. Update a book record" << endl;
     cout << "6. Add a book records" << endl;
     cout << "7. Delete a book record" << endl << endl;

     cout << "Your choice -> ";
     cin >> choice;

       char input1;
       char input;
        const int MAXRECORD = 1000;
        string  CallNum[MAXRECORD]= {"A010" , "C101" , "E180" , "E486", "S666"};
        string  Title[MAXRECORD] = {"Harry Potter" , "eCommerce", " Digital Signal Processing", "Optimal Control System", "A Brief History Of Time"};
       double Price[MAXRECORD] = {79.95, 115.48 , 68.45, 49.99, 15.25};
       int Copy[MAXRECORD] = {10, 3, 5, 2, 8};
        string book_number;
        char update_price;
        char update_copy;



     switch(choice)
     {
              case('0'):
                  return 0;       
                  break;

             //displaying one record
             case('1'):
                       system("CLS");
                start2:
                cout <<"Enter the book number -> " << endl;
                cin >> book_number;
               for(int i = 0; i < MAXRECORD; i++)

               if(book_number == CallNum[i])
               {
                    cout <<"CallNo               Title                           Price    NoCopy " << endl; 
                       cout <<"--------------------------------------------------------------------" << endl;
                       cout << setw (3) << CallNum[i] << setw (30) <<  Title[i] << setw (25) << fixed << setprecision (2) 
                           <<  Price[i] << setw (6) <<  Copy[i] << endl; 
                           break;
               }
               for(int i = 0; i < MAXRECORD; i++)
               if(book_number != CallNum[i])
               {
                              cout << "No record" << endl;
                              break;
               }


               cout << "Would you like a new search(Y/N): ";
               cin >> input;
               if (input == 'y' || input == 'Y')
               {
                   system("CLS");      
                  goto start2;       
               }    
              else if (input == 'n' || input == 'N')
              {
                   system("CLS");
                   goto start;
              }

               system("pause");

                system("CLS");
                goto start;
                break;

             //Query by first and last letter
             case('2'):
                       system("CLS");
                       start6:
                cout << "Enter the category code {'A', 'C', 'E', 'S' or 'U'} -> " << endl; 
                cin >> input1;
                if (input1 == 'A' || input1 == 'a')
                {
                          cout << "There are no books based on arts" << endl;
                }
                else if (input1 == 'C' || input1 == 'c' )
                {
                     cout << "There is one record" << endl;
                     cout <<"CallNo               Title                           Price    NoCopy " << endl; 
                       cout <<"--------------------------------------------------------------------" << endl;
                       cout << setw (3) << CallNum[1] << setw (30) <<  Title[1] << setw (25) << fixed << setprecision (2) 
                           <<  Price[1] << setw (6) <<  Copy[1] << endl;  
                }
                else if (input1 == 'E' || input1 == 'e')
                {
                     cout << "There are two records" << endl;
                    cout <<"CallNo               Title                           Price    NoCopy " << endl; 
                       cout <<"--------------------------------------------------------------------" << endl;
                       cout << setw (3) << CallNum[2] << setw (30) <<  Title[2] << setw (25) << fixed << setprecision (2) 
                           <<  Price[2] << setw (6) <<  Copy[2] << endl;

                       cout << setw (3) << CallNum[3] << setw (30) <<  Title[3] << setw (25) << fixed << setprecision (2) 
                           <<  Price[3] << setw (6) <<  Copy[3] << endl;     
                }
                else if (input1 == 'S' || input1 == 's')
                {
                     cout << "There are no books on science" << endl;
                }
                else if (input1 == 'U' || input1 == 'u')
                {
                     cout << "There are two records" << endl;
                     cout <<"CallNo               Title                           Price    NoCopy " << endl; 
                       cout <<"--------------------------------------------------------------------" << endl;
                       cout << setw (3) << CallNum[4] << setw (30) <<  Title[4] << setw (25) << fixed << setprecision (2) 
                           <<  Price[4] << setw (6) <<  Copy[4] << endl;
                           cout << setw (3) << CallNum[0] << setw (30) <<  Title[0] << setw (25) << fixed << setprecision (2) 
                           <<  Price[0] << setw (6) <<  Copy[0] << endl;
                }
                else
                {
                    cout << "Invalid choice" << endl;
                    goto start6;
                }
                system("pause");

                system("CLS");
                goto start;
                break; 

             //Query by price
             case('3'):
                    system("CLS");
                    int min, max;
                    cout << "Please enter the lower and upper bound of the price: " << endl;
                    cin >> min >> max;
                    if (min >= 0 && max <=49)
                    {
                         cout <<"CallNo               Title                           Price    NoCopy " << endl; 
                       cout <<"--------------------------------------------------------------------" << endl;
                       cout << setw (3) << CallNum[4] << setw (30) <<  Title[4] << setw (25) << fixed << setprecision (2) 
                           <<  Price[4] << setw (6) <<  Copy[4] << endl;   
                    }
                    else if (min <=15 && max <=68)
                    {

                         cout <<"CallNo               Title                           Price    NoCopy " << endl; 
                       cout <<"--------------------------------------------------------------------" << endl;
                       cout << setw (3) << CallNum[4] << setw (30) <<  Title[4] << setw (25) << fixed << setprecision (2) 
                            <<  Price[4] << setw (6) <<  Copy[4] << endl;
                       cout << setw (3) << CallNum[3] << setw (30) << Title[3] << setw (25) << fixed << setprecision (2)
                            << Price [3] << setw (6) << Copy[3] << endl;    
                    }
                    else if (min >=0 && max <=70)
                    {
                          cout <<"CallNo               Title                           Price    NoCopy " << endl; 
                       cout <<"--------------------------------------------------------------------" << endl;
                       cout << setw (3) << CallNum[4] << setw (30) <<  Title[4] << setw (25) << fixed << setprecision (2) 
                            <<  Price[4] << setw (6) <<  Copy[4] << endl;
                       cout << setw (3) << CallNum[3] << setw (30) << Title[3] << setw (25) << fixed << setprecision (2)
                            << Price [3] << setw (6) << Copy[3] << endl;  
                       cout << setw (3) << CallNum[2] << setw (30) << Title[2] << setw (25) << fixed << setprecision (2)
                            << Price [2] << setw (6) << Copy[2] << endl;      
                       }
                      else if (min >= 0 && max <=115)
                      {

                          cout <<"CallNo               Title                           Price    NoCopy " << endl; 
                       cout <<"--------------------------------------------------------------------" << endl;
                       cout << setw (3) << CallNum[4] << setw (30) <<  Title[4] << setw (25) << fixed << setprecision (2) 
                            <<  Price[4] << setw (6) <<  Copy[4] << endl;
                       cout << setw (3) << CallNum[3] << setw (30) << Title[3] << setw (25) << fixed << setprecision (2)
                            << Price [3] << setw (6) << Copy[3] << endl;  
                       cout << setw (3) << CallNum[2] << setw (30) << Title[2] << setw (25) << fixed << setprecision (2)
                            << Price [2] << setw (6) << Copy[2] << endl;
                       cout << setw (3) << CallNum[0] << setw (30) <<  Title[0] << setw (25) << fixed << setprecision (2) 
                            <<  Price[0] << setw (6) <<  Copy[0] << endl;
                       }
                      else if (min >= 0 && max > 115)
                      {
                            cout <<"CallNo               Title                           Price    NoCopy " << endl; 
                       cout <<"--------------------------------------------------------------------" << endl;
                       cout << setw (3) << CallNum[4] << setw (30) <<  Title[4] << setw (25) << fixed << setprecision (2) 
                            <<  Price[4] << setw (6) <<  Copy[4] << endl;
                       cout << setw (3) << CallNum[3] << setw (30) << Title[3] << setw (25) << fixed << setprecision (2)
                            << Price [3] << setw (6) << Copy[3] << endl;  
                       cout << setw (3) << CallNum[2] << setw (30) << Title[2] << setw (25) << fixed << setprecision (2)
                            << Price [2] << setw (6) << Copy[2] << endl;
                       cout << setw (3) << CallNum[0] << setw (30) <<  Title[0] << setw (25) << fixed << setprecision (2) 
                            <<  Price[0] << setw (6) <<  Copy[0] << endl; 
                       cout << setw (3) << CallNum[1] << setw (30) <<  Title[1] << setw (25) << fixed << setprecision (2) 
                            <<  Price[1] << setw (6) <<  Copy[1] << endl;
                       }
                       else if (min > 49 && max <68)
                       {
                                 cout <<"CallNo               Title                           Price    NoCopy " << endl; 
                       cout <<"--------------------------------------------------------------------" << endl;
                       cout << setw (3) << CallNum[3] << setw (30) << Title[3] << setw (25) << fixed << setprecision (2)
                            << Price [3] << setw (6) << Copy[3] << endl;  
                       }
                       else 
                       {
                            cout << "No books in this range " << endl;

                       }                      

                    system("pause");
                    system("CLS");
                    goto start;
                    break;




            //List all books
             case('4'):
                       system("CLS");

                           cout << "All books are listed below: " << endl;
                           cout << endl;
                           cout <<"CallNo               Title                           Price    NoCopy " << endl; 
                           cout <<"--------------------------------------------------------------------" << endl;
                           for (int i = 0; i < 5; i ++)
                           {
                               cout << setw (3) << CallNum[i] << setw (30) <<  Title[i] << setw (25) << fixed << setprecision (2) 
                               <<  Price[i] << setw (6) <<  Copy[i] << endl;
                           } 
                           system("pause");
                           system("CLS");
                           goto start;
                           break;


            //Updating 
            case('5'):
                   system("CLS");
                       start3:
                       cout << "Enter the book call number ->  " ;
                       cin >> book_number;
                       cout << endl << endl;

                        for(int i = 0; i < MAXRECORD; i++)

               if(book_number == CallNum[i])

               {
                     cout << "The record is: " << endl;          
                    cout <<"CallNo               Title                           Price    NoCopy " << endl; 
                       cout <<"--------------------------------------------------------------------" << endl;
                       cout << setw (3) << CallNum[i] << setw (30) <<  Title[i] << setw (25) << fixed << setprecision (2) 
                           <<  Price[i] << setw (6) <<  Copy[i] << endl << endl;
               }






                     cout << "Enter y or Y to update the price, if not press n or N to keep original. " << endl;
                       cin >> update_price;
                       cout << endl;

                       if (update_price == 'y' || update_price == 'Y')
                       {
                                        cout << "Enter the new price of the book -> " ;
                                        cin >> Price[MAXRECORD];

                                        cout << endl << endl;

                                       }
                       else if (update_price == 'n' || update_price == 'N')
                       {
                          goto start5;
                       }
                       start5:
                       cout << "Enter y or Y to update the credit points, if not press n or N to keep original. " << endl;
                       cin >> update_copy;
                        for(int i = 0; i < MAXRECORD; i++)
                       if (update_copy == 'y' || update_copy == 'Y')

                       {
                                        cout << "Enter the number of copies -> " ;
                                        cin >> Copy[i];
                                        Copy[i] = Copy[MAXRECORD]; 
                                        cout << endl << endl;
                       }
                       else if (update_copy == 'n' || update_copy == 'N')
                       {
                        cout << "Have completed the requested process. " << endl;
                         system("pause");
                       system("CLS");
                        goto start;
                       }

                        cout << "Have completed the requested process. " << endl;



                       system("pause");
                       system("CLS");
                       goto start;
                       break;          





             //New Record
             case('6'):
                       system("CLS");

                       cout << "Enter callnum -> " ;
                       cin >> CallNum[MAXRECORD];
                       for(int i = 0; i < MAXRECORD; i++)
                       CallNum[MAXRECORD] = CallNum[i];



                       cout << endl;
                       cout << "Have completed the requested process" << endl;
                       system("pause");
                       system("CLS");
                       goto start;
                       break;




            //Delete Record 
             case('7'):
                       system("CLS");
                       char *callnumber;
                       cout << "Enter the book call number -> " ;
                       cin >> callnumber;
                       cout << endl;
                       cout << "Having completed the requested process. " << endl;
                       system("pause");
                       system("CLS");
                       goto start;
                       break;

             default:
                     cout << "Invalid input! " << endl;
                     goto start;
                     break; 

}
cin.get();
return 0;
}

Wouldn't that be easier to have a Book class, which will hold information about a certain book, and then a repository, in which you'll add/update/store/delete/search for books?

class Book{
    string name, category;
    double price;
public:
    Book(){
        name=category="";
        price=0;
    }
    Book(string name, string category, double price){
        this->name=name;
        this->category=category;
        this->price=price;
    }

    void setName(string name){
        this->name=name;
    }

    void setCategory(string category){
        this->category=category;
    }

    void setPrice(double price){
        this->price=price;
    }

    const string& getName() const{
        return name;
    }

    const string& getCategory() const{
        return category;
    }

    const double getPrice(){
        return price;
    }
};

Here's a quick example. And, you'll have to create another class, for example BookRepo, in which you'll store elements of type Book, and do operations on them:

#include <vector>
using namespace std;

class BookRepo{
    vector<Book> list;
public:
    BookRepo(){
    // class information.
    }
};

Could you explain about this to me a bit further with examples as i am new to class and array

As a design principle you make clsses when you are modeling real world objects. In your case book is a real world object. Books have attributes like name,category,price so these are kept together in a class. You can then focus your development work on Book as a whole and do not need to worry about individual attributes of the book.
Also it is better to divide such a long program into functions. You can do so even if you are not familiar with classes.This way your code will easier to maintaion and you need to check for errors in specific functions.This will help you find bugs easily.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.