Hello,

Well I am trying to finished the following progam and I need help with 2 functions [i]reverse book(s)[/i] and [i]return book[/i]... If someone can told me points where to start I will appritieate:: below is my code, note that I don't know if the [i]customer_book_count[/i] is work since I can't check it without the others functions::: Thank you in advance!!! Regards!!!!

#include<iostream>
#include<cmath>
#include <stdio.h>
#include <string.h>
#include <cassert>

using namespace std;

int const MAXCUSTOMERS = 100;


struct Customer
{
  char id[40];
  char name[40];
  char address[40];
  char customer_id[40];
};

struct Book
{
  char title[40];
  char author[40];
  char ISBN[40];
  char date[40];

  int book_counter[5];
};

Customer customer_list[MAXCUSTOMERS];
Customer customer_temp;

//functions declaration
int borrow_books(Customer customers[], Customer &customer, Book book_list[], Book &books,int &number_customers,int &number_books, bool &return_main,int &total_books_customer, int &ID_Customer);
bool get_customer(Customer customers[], Customer &customer, Book book_list[], Book &books,int &number_customers,int &number_books, bool& return_main,  int &ID_Customer,int &total_books_customer);
bool print_customers(Customer customers[], Customer &customer, Book book_list[], Book &books,int &number_customers,int &number_books, bool& return_main,int &total_books_customer, int &ID_Customer);
bool find_customers(Customer customers[], Customer &customer, Book book_list[], Book &books,int &number_customers,int &number_books, bool& return_main, int &ID_Customer,int &ID_Customer_count);
bool return_num_customers(int &number_customers,bool& return_main);

// get customer data from user
bool get_customer(Customer customers[], Customer &customer, Book book_list[], Book &books,int &number_customers,int &number_books, bool& return_main, int &ID_Customer, int &total_books_customer)
{
char opt;
bool found = true;

      cout << "Enter customer id: ";
      cin.getline(customer.id,40);


for (int i=0; i<number_customers;i++){
if (strcmp(customer.id,customers[i].id)==0)
{    found = false;
     cout << "\nThe customer with ID: "<<customer.id<<" exist";
     return (0);
}
else
    found =true;}
if (found == true)
{
    cout << "Enter the customer name : ";
      cin.getline(customer.name, 40);

      cout << "Enter the customer address:";
      cin.getline(customer.address,40);

          customers[number_customers] = customer;
          ++number_customers;

      cout << "Do you want to borrow 1 book(y/n)?";
      cin >> opt;

      if (opt =='Y' or opt == 'y'){
          cin.ignore();


        cout << "Enter book title: ";
        cin.getline(books.title,40);

        cout << "Enter book author: ";
        cin.getline(books.author,40);

        cout << "Enter book ISBN: ";
        cin.getline(books.ISBN,40);

        cout << "Enter borrow date: ";
        cin.getline(books.date,40);

          book_list[number_books] = books;
          total_books_customer =number_books++;

          cout << "\nGet a customer";
          cout << "\nCustomer "<<number_customers<<" with ID: "<<customer.id;
          cout << "\nThe customer was borrow "<<total_books_customer<<" book";
          cout << "\n=============================="<< endl;
      }
      else {
          cout << "\nGet a customer";
          cout << "\nTotal Customer(s) "<<number_customers<<" with ID: "<<customer.id;
          cout << "\n=============================="<< endl;
      }}
  return true;
}
// add a customer to the customer list
//   and update number of customers
bool return_num_customers(int &number_customers,bool& return_main)    //is working
{
     cout << "\n================================";
     cout << "\nReturn the number of customer(s)";
     cout << "\n--------------------------------";
     cout << "\n Total number of customer(s) = "<<number_customers;
     cout << "\n        ** END OF **            ";
     cout << "\n================================";
     return return_main = true;
}

// print the customers in the customer list
bool print_customers(Customer customers[], Customer &customer, Book book_list[], Book &books,int &number_customers,int &number_books, bool& return_main,int &total_books_customer, int &ID_Customer)
{
    bool found = true;
    cout <<"Enter the customer id: ";
    cin.getline(customer.id,40);

    for (int i=0; i<=number_customers;i++){
        if (strcmp(customer.id,customers[i].id)==0)
        {    found = false;
          cout << "\n========================";
          cout << "\nThe customer was found..";
          cout << "\n------------------------";
          cout << "\nID: "<<customers[i].id;
          cout << "\nName: "<<customers[i].name;
          cout << "\nAddress: "<<customers[i].address;
          cout << "\n      ** END OF **      ";
          cout << "\n========================";
          return (1);
        }else
            found =true;}
    if (found == true){
                  cout << "\n========================================";
                  cout << "\n          Print Customer(s)             ";
                  cout << "\nThere isn't any customer with this ID: "<<customer.id;
                  cout << "\n            ** END OF **                ";
                  cout << "\n========================================";
                  return (0);}
    return (0);
        }

bool find_customers(Customer customers[], Customer &customer, Book book_list[], Book &books,int &number_customers,int &number_books, bool& return_main, int &ID_Customer,int &ID_Customer_count)
{

    bool found = true;
    cout <<"Enter the customer id: ";
    cin.getline(customer.id,40);

    for (int i=0; i<number_customers;i++){
    if (strcmp(customer.id,customers[i].id)==0)
    {    found = false;
                  cout << "\n=============================================";
                  cout <<  "\n              3:Find Customer                ";
                  cout <<  "\n         The customer was found              ";
                  cout <<  "\n    There are "<<number_customers<< " customer in database";
                  cout <<  "\n               ** END OF **                  ";
                  cout <<  "\n=============================================";
         return (0);
    }
    else
        found =true;}
        if (found == true)
        {
                cout << "\n=============================================";
                cout << "\n              Print Customer                 ";
                cout << "\n  There isn't any customer with this ID: "<<customer.id;
                cout << "\n               ** END OF **                  ";
                cout << "\n=============================================";
                return (1);
        }
return true;
}

int borrow_books(Customer customers[], Customer &customer, Book book_list[], Book &books,int &number_customers,int &number_books, bool& return_main, int &total_books_customer, int &ID_Customer){


    bool found = true;
        cout <<"Enter the customer id: ";
        cin.getline(customer.id,40);

        for (int i=0; i<number_customers;i++){
        if (strcmp(customer.id,customers[i].id)==0)
        {    found = false;

        cout <<"How many book(s) want to borrow?(<5)";
    cin >>number_books;
    cin.ignore();

    for (int j=0; j<number_books; j++){
                                cout << "\nEnter the title: ";
                                cin.getline(book_list[i].title,40);                 //TEST

                                cout << "\nEnter the author: ";
                                cin.getline(book_list[i].author,40);

                                cout << "\nEnter the ISBN: ";
                                cin.getline(book_list[i].ISBN,40);

                                cout << "\nEnter the date: ";
                                cin.getline(book_list[i].date,40);
                                total_books_customer+=number_books;
                                cout <<"\nThe customer with id: "<<customer.id<<" has "<<total_books_customer<<" of 5 book(s)";
}        return (0);
                    }
                        else
                            found =true;}
                                    if (found == true){
                                                        cout << "\n===========================================";
                                                        cout << "\n            Borrow Book(s)                 ";
                                                        cout << "\nThere isn't any customer with this ID: "<<customer.id;
                                                        cout << "\n             ** END OF **                  ";
                                                        cout << "\n===========================================";
                                                        return (1);}
return true;
}
int main()
{


  Customer customer_temp;
  Book books_temp;
  Book book_list[MAXCUSTOMERS];
  int ID_Customer = 0;
  int ID_Customer_count =0;
  int number_customers = 0;
  int number_books = 0;
  int total_books_customer = 0;
  bool return_main = true;
  char option;


  do {
  cout << "\n";
  cout << "====================================="<<    endl;
  cout << "    Welcome to book store!!!         "<<    endl;
  cout << "====================================="<<    endl;
  cout <<"1: Read a customer                    "<<    endl;
  cout <<"2: Return the number of customers     "<<    endl;
  cout <<"3: Find a customer                    "<<    endl;
  cout <<"4: Print details of customer          "<<    endl;
  cout <<"5: Borrow book(s)                     "<<    endl;
  cout <<"6: Reserver book(s)                   "<<    endl;
  cout <<"7: Return book                        "<<    endl;
  cout <<"8: Reports                            "<<    endl;
  cout <<"9: Calculate and print fines          "<<    endl;
  cout << "====================================="<<    endl;
  cout <<"Select one of the options: ";
  cin >> option;
  cin.ignore();

  switch (option)
  {
        case '1':{          get_customer(customer_list, customer_temp,book_list, books_temp,number_customers,number_books,return_main,ID_Customer,total_books_customer);
                        }    break;

  case '2':   return_num_customers(number_customers,return_main);
      break;
  case '3':   find_customers(customer_list, customer_temp,book_list, books_temp,number_customers,number_books,return_main,ID_Customer,ID_Customer_count);
      break;
  case '4':   print_customers(customer_list, customer_temp,book_list, books_temp,number_customers,number_books,return_main,total_books_customer,ID_Customer);
      break;
  case '5':   borrow_books(customer_list, customer_temp,book_list, books_temp,number_customers,number_books,return_main, total_books_customer,ID_Customer);
      break;
  case '6':
      break;
  case '7':
      break;
  case '8':
      break;
  case '9':
      break;
  }
  }
  while (return_main!=false);
     cout <<"Have a nice day"<<endl;
     }

If you want an answer, you must reduce the problem down to the more essential parts of the code, and provide more details as to what the problem actually is. You can't expect people to go through all this code and figure out by themselves what the problem is, and eventually suggest a solution. If you could point more directly at the errors and provide more details as to what it does and what it should do (or what you expect it to do).

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.