this is my program (isn't it nice ) the problem i'm having is that the program stops after "search" is selected but there should be another option.....does anyone know why?
and i've been told i should apologise for my earlier
thread.
Code:
#include <iostream.h>
#include <fstream.h>
#include <stdio.h>
#include <conio.h>
#include <string.h>
char choice,type,choose,decide;
int e,s,c,p,a;
//-----------------------------------
//base and derived classes
class books {
public:
struct database {
char title[256];
char author[256];
char isbn[11];
char publishername[256];
char cdrom[4];
char yearofpub[5];
char price[5];
}np[20]; // end of struct
//..........................
void search(int);
void enter(int);
void remove(void);
void first(void);
void author(void);
void pub(void);
};
//------------------------------------
class store: public books{
public:
void save(void);
void load(void);
};
//------------------------------------
int main(int) {
books bdata;
store storage;
storage.first();
return(0);
};
//------------------------------------
void books::first(void) {
cout<<"-----------------------------------------------------------\n";
cout<<"| |\n";
cout<<"| Welcome to the Book |\n";
cout<<"| Database |\n";
cout<<"| |\n";
cout<<"-----------------------------------------------------------\n\n\n\n";
cout<<" What would you like to do? \n";
cout<<" Select:\n\n";
cout<<" 1 To add a book\n";
cout<<" 2 To search for a book\n";
cout<<" 3 To remove a book\n";
cout<<" 4 Clear book database\n";
cout<<" 5 Show all books\n";
choice=getchar();
choice=toupper(choice);
switch(choice) {
case '1': {
cout<<"you selected 'Add'\n";
enter(e);
break;}
case '2': {
cout<<"you selected 'Search'\n";
search(s);
break;}
case '3': {
cout<<"you selected 'Remove'\n";
break;}
case '4': {
cout<<"you selected 'Clear'\n";
break;}
case '5': {
cout<<"you selected 'show all'\n";
break;}
};
};
//---------------------------------------
//member functions
void books::enter(int e) {
cout<<"Enter the book title: ";
cin>>(np[e].title);
cout<<"Enter the author: ";
cin>>(np[e].author);
cout<<"Enter the ISBN number: ";
cin>>(np[e].isbn);
cout<<"Enter the publisher name: ";
cin>>(np[e].publishername);
cout<<"Is there a CDROM included (yes or no): ";
cin>>(np[e].cdrom);
cout<<"Year published: ";
cin>>(np[e].yearofpub);
cout<<"Enter price - exclude sign: ";
cin>>(np[e].price);
};
//------------------------------------------
void books::search(int s) {
cout<<"-----------------------------------------------------------\n";
cout<<"| |\n";
cout<<"| Welcome to the Book |\n";
cout<<"| Database |\n";
cout<<"| |\n";
cout<<"-----------------------------------------------------------\n\n\n\n";
cout<<" What would you like to search by? \n";
cout<<" Select:\n\n";
cout<<" 1 Author.\n";
cout<<" 2 Publisher\n";
choose=getchar();
choose=toupper(choose);
switch(choose) {
case 'A': {
cout<<"you selected 'Search by Author'\n";
author();
break;}
case 'B': {
cout<<"you selected 'Search by Publisher'\n";
pub();
break;}
};
};
void books::author() {
cout<<"Enter the book title: ";
cin>>(np[a].title);
cout<<"Enter the author: ";
cin>>(np[a].author);
cout<<"Enter the ISBN number: ";
cin>>(np[a].isbn);
cout<<"Enter the publisher name: ";
cin>>(np[a].publishername);
cout<<"Is there a CDROM included (yes or no): ";
cin>>(np[a].cdrom);
cout<<"Year published: ";
cin>>(np[a].yearofpub);
cout<<"Enter price - exclude sign: ";
cin>>(np[a].price);
};
void books::pub() {
cout<<"Enter the book title: ";
cin>>(np[p].title);
cout<<"Enter the author: ";
cin>>(np[p].author);
cout<<"Enter the ISBN number: ";
cin>>(np[p].isbn);
cout<<"Enter the publisher name: ";
cin>>(np[p].publishername);
cout<<"Is there a CDROM included (yes or no): ";
cin>>(np[p].cdrom);
cout<<"Year published: ";
cin>>(np[p].yearofpub);
cout<<"Enter price - exclude sign: ";
cin>>(np[p].price);
};