This document was uploaded by user and they confirmed that they have the permission to share
it. If you are author or own the copyright of this book, please report to us by using this DMCA
report form. Report DMCA
Book_Data book[100] character choice[15] character flag[10] read_file(book, num) DO { DO { INPUT choice WHILE (strlen(choice) > 1 || choice[0] < 1 || choice[0] > 8) { DISPLAY invalid input. Please try again: DISPLAY please select the option code [1-8]: INPUT
choice
} } WHILE (strlen(choice) > 1 || choice[0] < 1 || choice[0] > 8); SWITCH { CASE 1 : list BREAK CASE 2 : search_isbn_number BREAK CASE 3 : search_by_keyword BREAK CASE 4 : show_low_inventories BREAK CASE 5 : update_book read_file BREAK CASE 6 : add_book read_file
BREAK CASE 7 : delete_book read_file BREAK CASE 8 : exit BREAK } DISPLAY Do you wish to continue your program by returning to main menu? ( 1-Yes , 0-No ) INPUT
{ DISPLAY Invalid input. Please Try Again: DISPLAY Do you wish to continue your program by returning to main menu? (1-Yes , 0-No) INPUT
flag
} } WHILE flag = 1 EXIT }
{ DISPLAY WELCOME to book records DISPLAY Please choose any options below to continue DISPLAY 1) Display list of records DISPLAY 2) Search by ISBN number DISPLAY 3) Search by key word DISPLAY 4) Show low inventories
DISPLAY 5) Update information DISPLAY 6) Add book DISPLAY 7) Delete Book DISPLAY 8) Exit
DISPLAY
Please Select The Option Code [ 1-8 ]:
}
{
string line Set i = 0 ifstream inFile(bookstore.txt) IF(inFile) { WHILE(getline) book[i].book_name book[i].isbn_number book[i].author book[i].edition book[i].year book[i].quantity. } } ELSE { WHILE(inFile) { DISPLAY
The text file is missing!
EXIT } inFile close
}
{ DISPLAY DISPLAY DISPLAY DISPLAY DISPLAY DISPLAY
Book name ISBN number Author Edition Year Quantity
FOR ( i = 1; i < num; i++) { DISPLAY book[i].book_name; DISPLAY book[i].isbn_number; DISPLAY book[i].author; DISPLAY book[i].edition; DISPLAY book[i].year; DISPLAY book[i].quantity; } }
{
file_isbn_number, count = 0, alp = 0 character flag[10], isbn_number[50] string str_isbn_number DO {
DISPLAY
Please enter ISBN number of book
INPUT
isbn_number
alp = checking_for_alphabet(isbn_number); FOR (i = 0; i < num; i++) { str_isbn_number = book[i].isbn_number IF (isbn_number == str_isbn_number) {
DISPLAY DISPLAY DISPLAY DISPLAY DISPLAY DISPLAY
Book name ISBN number Author Edition Year Quantity
Do you wish to continue searching the book by using ISBN number? (1-Yes, 0-No) flag
WHILE (flag[0] =1 && flag[0] = 0 || strlen(flag) > 1) { DISPLAY Invalid Input. Please Try Again DISPLAY Do you wish to continue searching the book by using ISBN number? (1-Yes, 0-No) INPUT flag } } WHILE (flag[0] = 1) }
Book name ISBN number Author Edition Year Quantity
FOR (i = 0; i < num; i++) { temp[i].book_name.resize(book[i].book_name.size()); temp[i].isbn_number.resize(book[i].isbn_number.size()); temp[i].author.resize(book[i].author.size()); temp[i].edition.resize(book[i].edition.size()); temp[i].year.resize(book[i].year.size()); temp[i].quantity.resize(book[i].quantity.size());
IF (((temp[i].book_name.find(keyword) != string::npos) (temp[i].isbn_number.find(keyword) != string::npos)
Invalid Input. Please Try Again Do you really want to update book?(1-Yes, 0-No)
INPUT
flag
} IF (flag[0] =1) { DISPLAY Enter the book name you wish to update INPUT book_name for ( i = 0; i < num; i++) { if (book_name == book[i].book_name) { DISPLAY Please key in the new data for the book DISPLAY ISBN number: INPUT book[i].isbn_number DISPLAY Author of the book INPUT book[i].author DISPLAY Edition of the book INPUT book[i].edition DISPLAY Year of the book INPUT book[i].year DISPLAY Quantity INPUT book[i].quantity update = true } } if (update = true) { outFile(bookstore.txt) FOR ( i = 0; i < num; i++) { outFile book[i].book_name book[i].isbn_number book[i].author book[i].edition book[i].year book[i].quantity }
DISPLAY outFile close
Updated successfully !
} ELSE { DISPLAY No record found! update = false } }
} while (flag[0] = 1)
} { Book_Data new_data new_book character flag[10] DO { DISPLAY Do you really want to add any book?(1-Yes, 0-No) INPUT flag WHILE (flag[0] = 1 && flag[0] = 0|| strlen(flag) > 1) { DISPLAY DISPLAY INPUT
Invalid Input. Please Try Again Do you really want to add any book?(1-Yes, 0-No) flag
{ string isbn_number; bool delete_option = false count = 0; character flag[10] DO { ofstream (temp.txt)
DISPLAY Do you really want to delete any book?(1-Yes, 0-No) INPUT flag while (flag[0] = 1 && flag[0] = 0 || strlen(flag) > 1) { DISPLAY Invalid Input. Please Try Again DISPLAY Do you really want to delete any book?(1-Yes, 0-No) INPUT flag } if (flag[0] == '1') {
DISPLAY Enter the ISBN number that you wish to delete INPUT isbn_number FOR (i = 0; i < num; i++) { IF (isbn_number = book[i].isbn_number) {
IF (delete_option = false) { DISPLAY The isbn number is not found! } else { DISPLAY The isbn number is deleted! ifstream inFile(bookstore.txt) IF (inFile) { DISPLAY EXIT } ELSE { i = 0;