Pseudo Code

  • Uploaded by: Saravanan Raj
  • 0
  • 0
  • August 2019
  • PDF

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


Overview

Download & View Pseudo Code as PDF for free.

More details

  • Words: 1,233
  • Pages: 14
{

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

flag

WHILE (flag[0] = 1 && flag[0] = 0 || strlen(flag) > 1)

{ 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

DISPLAY DISPLAY DISPLAY DISPLAY DISPLAY DISPLAY

book[i].book_name book[i].isbn_number book[i].author book[i].edition book[i].year book[i].quantity

} } IF (count = 0) {

DISPLAY

No record Found

} count = 0 DISPLAY INPUT

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) }

{ alp = 0; FOR ( i = 0; i < strlen(book); i++) {

IF(isalpha(book[i])) } }

{ Book_Data temp[50] string keyword count = 0; char flag[10]; DO { DISPLAY INPUT

Enter the first keyword that you wish to find Keyword

transform(keyword.begin(), keyword.end(), keyword.begin(), tolower) DISPLAY DISPLAY DISPLAY DISPLAY DISPLAY DISPLAY

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)

(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 DISPLAY DISPLAY DISPLAY DISPLAY DISPLAY

book[i].book_name; book[i].isbn_number; book[i].author; book[i].edition; book[i].year; book[i].quantity

} ;

} IF (count = 0) { DISPLAY

No record found !

} count = 0 DISPLAY INPUT

Do you wish to continue searching any keyword from the text file? (1-Yes, 0-No) flag

WHILE (flag[0] = 1 && flag[0] = 0 || strlen(flag) > 1) { DISPLAY DISPLAY

Invalid Input. Please Try Again: \n"; Do you wish to continue searching any keyword from the text file? (1-Yes, 0-No)

INPUT

flag

} } WHILE (flag[0] = 1) }

{ string str_quantity file_quantity count = 0 DISPLAY

Book name

DISPLAY DISPLAY DISPLAY DISPLAY DISPLAY

ISBN number Author Edition Year Quantity

FOR (i = 1; i < num; i++) { str_quantity = book[i].quantity; IF (file_quantity<10) { DISPLAY DISPLAY DISPLAY DISPLAY DISPLAY DISPLAY }

book[i].book_name book[i].isbn_number book[i].author book[i].edition book[i].year book[i].quantity

} IF (count = 0) { DISPLAY }

No records found!

}

{ string book_name; character flag[3] string answer bool update = false DO { DISPLAY INPUT

Do you really want to update book?(1-Yes, 0-No) flag

WHILE (flag[0] = ' && flag[0] = 0 || strlen(flag) > 1) {

DISPLAY DISPLAY

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

} IF (flag[0] = 1) { book += 1 new_book = book;

DISPLAY INPUT

Enter the book name new_data.book_name

DISPLAY INPUT

Enter the ISBN Number new_data.isbn_number

DISPLAY INPUT

Enter the Author new_data.author

DISPLAY INPUT

Enter the Edittion new_data.edition

DISPLAY INPUT

Enter the Year new_data.year

DISPLAY INPUT

Enter the Quantity new_data.quantity

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

Added successfully !

DISPLAY DISPLAY DISPLAY DISPLAY DISPLAY DISPLAY

Book name ISBN number Author Edition Year 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 DISPLAY

Redirecting back to main menu

} WHILE (flag[0] = 1); }

{ 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) {

temp temp temp temp temp temp

book[i].book_name book[i].isbn_number book[i].author book[i].edition book[i].year book[i].quantity

} ELSE { delete_option = true; } } 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 EXIT } ELSE { i = 0;

Error opening input file

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 DISPLAY EXIT }

THANK YOU **EXITING THE PROGRAM**

Related Documents

Pseudo Code
August 2019 43
Pseudo Code
April 2020 22
Pseudo Code Coin Changing
December 2019 26
Pseudo
November 2019 30

More Documents from ""

Pseudo Code
August 2019 43
P13 E1 Saravanan Raj
August 2019 40
Apple
August 2019 53
Maya08 Broch Overview V17 1
December 2019 43
Minggu 1
August 2019 39
Kehadiran Mesyuarat Pj
August 2019 60