Pseudo Code
Pseudo Code
Book_Data book[100]
character choice[15]
character flag[10]
read_file(book, num)
DO
DO
INPUT choice
INPUT choice
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 flag
{
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 8) Exit
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)
EXIT
inFile close
}
{
DISPLAY Book name
DISPLAY ISBN number
DISPLAY Author
DISPLAY Edition
DISPLAY Year
DISPLAY Quantity
{
file_isbn_number, count = 0, alp = 0
character flag[10], isbn_number[50]
string str_isbn_number
DO
alp = checking_for_alphabet(isbn_number);
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
}
}
IF (count = 0)
{
} WHILE (flag[0] = 1)
}
{
alp = 0;
}
}
Book_Data temp[50]
string keyword
count = 0;
char flag[10];
DO
{
DISPLAY Enter the first keyword that you wish to find
INPUT Keyword
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)
(temp[i].author.find(keyword) != string::npos)
(temp[i].edition.find(keyword) != string::npos)
(temp[i].year.find(keyword) != string::npos)
(temp[i].quantity.find(keyword) != string::npos)))
{
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
}
}
; IF (count = 0)
{
DISPLAY No record found !
}
count = 0
DISPLAY Do you wish to continue searching any keyword from the text
file? (1-Yes, 0-No)
INPUT flag
INPUT flag
}
} WHILE (flag[0] = 1)
}
{
string str_quantity
file_quantity
count = 0
IF (file_quantity<10)
{
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
}
}
IF (count = 0)
{
DISPLAY No records found!
}
}
{
string book_name;
character flag[3]
string answer
bool update = false
DO
{
DISPLAY Do you really want to update book?(1-Yes, 0-No)
INPUT flag
INPUT flag
}
IF (flag[0] =1)
{
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 Updated successfully !
outFile close
ELSE
{
} 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
ofstream outFile
outFile open(bookstore.txt)
outFile new_data.book_name
new_data.isbn_number
new_data.author
new_data.edition
new_data.year
new_data.quantity
DISPLAY new_data.book_name
DISPLAY new_data.isbn_number;
DISPLAY new_data.author;
DISPLAY new_data.edition;
DISPLAY new_data.year;
DISPLAY new_data.quantity;
outFile close
}
ELSE
{
string isbn_number;
bool delete_option = false
count = 0;
character flag[10]
DO
{
ofstream (temp.txt)
temp close
remove (bookstore2.txt)
rename (bookstore.txt, bookstore2.txt)
rename (temp.txt, bookstore.txt)
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 Error opening input file
EXIT
}
ELSE
{
i = 0;
WHILE getline(inFile)
{
book[i].book_name = data;
book[i].isbn_number = data;
book[i].author = data;
book[i].edition = data;
book[i].year = data;
book[i].quantity = data;
inFile close
}
}
}
delete_option = false
} while (flag[0] = 1)
{
DISPLAY THANK YOU
DISPLAY **EXITING THE PROGRAM**
EXIT
}