Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- See how your visitors are really using your website.
- TRY IT FOR FREE
- HIDE AD • AD VIA BUYSELLADS
- PASTEBINnew pastePRO API tools faq deals
- search...
- Guest User
- -
- Public Pastes
- Untitled
- 0 sec ago
- Untitled
- 2 sec ago
- Untitled
- 4 sec ago
- Untitled
- 5 sec ago
- wwe
- JavaScript | 8 sec ago
- Untitled
- 15 sec ago
- Weak
- 19 sec ago
- Untitled
- 21 sec ago
- daily pastebin goal
- 52%
- help support pastebin
- SHARE
- TWEET
- Untitled
- A GUEST MAR 22ND, 2019 1 IN 29 DAYS
- Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- rawdownloadcloneembedreportprint text 13.10 KB
- Pseudo code for Programming Project 5 – Due 3/21/2019
- This project involves completing Programming Exercise 12 at the end of chapter 10.
- A. Add an include for the following bookType header :
- class bookType
- {
- public:
- void setBookInfo(string title, string ISBN,
- string Publisher, int PublishYear,
- string auth[], double cost, int copies,
- int noAuthors);
- void setBookTitle(string s);
- void setBookISBN(string s);
- void setBookPrice(double cost);
- void setCopiesInStock(int noOfCopies);
- void printInfo() const;
- bool isISBN(string s) const;
- bool isTitle(string s) const;
- bool isAuthor(string s) const;
- void getBookTitle(string& s) const;
- void getBookISBN(string& s) const;
- double getBookPrice() const;
- bool isInStock() const;
- void makeSale();
- void printBookPrice() const;
- void printbookTitle() const;
- void printbookTitleAndISBN() const;
- void showQuantityInStock() const;
- void updateQuantity(int addBooks);
- bookType();
- private:
- string bookTitle;
- string bookISBN;
- string bookPublisher;
- int bookPublishYear;
- string authors[4];
- double price;
- int quantity;
- int noOfAuthors;
- };
- B. Declare the following prototypes :
- void getBookData(bookType books[], int& noOfBooks);
- void printBookData(bookType books[], int noOfBooks);
- void searchBookData(bookType books[], int bookCount);
- void searchBookDataByISBN(bookType books[], int bookCount, string ISBN,
- int& loc);
- void searchBookDataByTitle(bookType books[], int bookCount, string title,
- int& loc);
- void updateCopiesInStock(bookType books[], int bookCount);
- plus two more :
- 1. One to show the main menu
- 2. One to show the submenu
- C. In the mainline :
- Declare an array to store up to 100 books. The array will be of the type
- bookType.
- Declare an int variable to store the number of books in the array.
- Declare an int variable to store the user’s choice when they use the menu
- Set manipulators so the prices are outputted with 2 decimal positions.
- Call the getBookData function
- Call the showMenu function
- Accept the user’s choice
- While user’s choice not equal 9:
- Use a switch structure to interrogate the value of choice. There are 5 cases
- which correspond to the menu and the default case:
- For case 1: Write the code to loop through the books array. For each
- element in the array, invoke the class member function
- printbookTitle().
- For case 2: Write the code to loop through the books array. For each
- element in the array, invoke the class member function
- printbookTitleAndISBN().
- For cases 3, 4 and 5: Call the appropriate function
- Call the showMenu function
- Accept the user’s choice
- End program.
- D. After the mainline :
- Define the non-class member functions called within the mainline.
- 1. getBookData function :
- void getBookData(bookType books[], int& noOfBooks)
- {
- string title;
- string ISBN;
- string Publisher;
- int PublishYear;
- string auth[4];
- double cost;
- int copies;
- int authorCount;
- int i, j;
- - Declare an input file called infile.
- - Open the input file and verify it is opened successfully. If not, terminate
- the program.
- char ch;
- infile >> noOfBooks;
- infile.get(ch);
- for (i = 0; i < noOfBooks; i++)
- {
- getline(infile, title);
- getline(infile,ISBN);
- getline(infile,Publisher);
- infile >> PublishYear >> cost >> copies >> authorCount;
- infile.get(ch);
- for (j = 0; j < authorCount; j++)
- getline(infile, auth[j]);
- books[i].setBookInfo(title, ISBN, Publisher,
- PublishYear, auth, cost, copies,
- authorCount);
- }
- }
- 2. searchBookData function :
- void searchBookData(bookType books[], int bookCount)
- {
- int choice;
- char ch;
- int loc;
- string str;
- Call the submenu function
- Accept user’s choice
- Use a switch structure to interrogate the value of choice. There are 3 cases
- which correspond to the menu and the default case:
- For case 1: Prompt and accept ISBN
- Call searchBookDataByISBN
- If loc not equal to -1 state that the store sells the book.
- Otherwise, state the store does not.
- For case 2: Prompt and accept Book Title
- Call searchBookDataByTitle
- If loc not equal to -1 state that the store sells the book.
- Otherwise, state the store does not.
- 3. searchBookDataByISBN function :
- This is the code to locate the index of the books array where the ISBN is found :
- {
- int i;
- loc = -1;
- for (i = 0; i < bookCount; i++)
- if (books[i].isISBN(ISBN))
- {
- loc = i;
- break;
- }
- }
- 4. searchBookDataByTile function : Model code after searchBookDataByISBN
- function
- 5. updateCopiesInStock function
- {
- int choice;
- int loc;
- int count;
- char ch;
- string str;
- Call the submenu function
- Accept user’s choice
- Use a switch structure to interrogate the value of choice. There are 3 cases
- which correspond to the menu and the default case:
- For case 1: Prompt and accept ISBN
- Call searchBookDataByISBN
- If loc not equal to -1
- prompt and accept number of books
- call the class member function updateQuantitiy.
- Otherwise, state the store does not sell book.
- For case 2: Prompt and accept Book Title
- Call searchBookDataByTitle
- If loc not equal to -1
- prompt and accept number of books
- call the class member function updateQuantitiy.
- Otherwise, state the store does not sell book.
- 6. printBookData function :
- Write the code to loop through the books array. For each element in the
- array, invoke the class member function printInfo(). See the sample execution
- below for the output
- 7. showMenu function :
- Outputs :
- Welcome to Rock's Book Store
- To make a selection enter the number and press enter
- 1: Print a list of books
- 2: Print a list of books and ISBN numbers
- 3: To see if a book in store
- 4: To update the number of copies of a book
- 5: To print books data
- 9: Exit the program.
- 8. subMenu function :
- Outputs :
- Enter
- 1: To search the book by ISBN
- 2: To search the book by title
- E. Implementation File :
- Define the class member functions :
- void bookType::setBookInfo(string title, string ISBN,
- string Publisher, int PublishYear,
- string auth[], double cost, int copies,
- int authorCount)
- {
- Set all the private class members to parmeters. Note that there can be up to
- 4 authors per book.
- }
- void bookType::setBookTitle(string s)
- {
- bookTitle = s;
- }
- setBookISBN : Follow setBookTitle function definition
- setBookPrice : Follow setBookTitle function definition
- setCopiesInStock : Follow setBookTitle function definition
- printInfo: Output the contents of the private variables per execution
- example. For instance :
- Title: C++Programing: From Problem Analysis to Program Design
- ISBN: 5-17-525281-3
- Publisher: ABC
- Year of Publication: 2000
- Number of Authors: 1
- Authors: Malik, D.S.;
- Price: 52.5
- Quantities in stock: 20
- bool bookType::isISBN(string s) const
- {
- return (bookISBN == s);
- }
- isTitle Follow bookType::isISBN function definition
- bool bookType::isAuthor(string s) const
- {
- bool found = false;
- int i;
- for (i = 0; i < noOfAuthors; i++)
- if (authors[i] == s)
- {
- found = true;
- break;
- }
- return found;
- }
- void bookType::getBookTitle(string& s) const
- {
- s = bookTitle;
- }
- getBookISBN Follow getBookTitle function definition
- double bookType::getBookPrice() const
- {
- return price;
- }
- bool bookType::isInStock() const
- {
- return (quantity > 0);
- }
- void bookType::makeSale()
- {
- quantity--;
- }
- void bookType::printBookPrice() const
- {
- cout << "Price = " << price << endl;
- }
- printbookTitle Follow printBookPrice function definition
- printbookTitleAndISBN Follow printBookPrice function definition
- showQuantityInStock Follow printBookPrice function definition
- void bookType::updateQuantity(int addBooks)
- {
- quantity = quantity + addBooks;
- }
- bookType::bookType()
- {
- int i;
- bookTitle = "";
- bookISBN = "";
- bookPublisher = "";
- bookPublishYear = 1900;
- noOfAuthors = 0;
- for (i = 0; i < 4; i++)
- authors[i] = "";
- price = 0;
- quantity = 0;
- }
- (See next page for a sample execution)
- F. Sample execution :
- Welcome to Rock's Book Store
- To make a selection enter the number and press enter
- 1: Print a list of books
- 2: Print a list of books and ISBN numbers
- 3: To see if a book in store
- 4: To update the number of copies of a book
- 5: To print books data
- 9: Exit the program.
- 2
- Title: C++Programing: From Problem Analysis to Program Design; ISBN: 5-17-525281-3
- Title: Fuzzy Discrete Structures; ISBN: 3-7908-1335-4
- Title: Fuzzy Mathematic in Medicine; ISBN: 3-7908-1325-7
- Title: Harry John and The Magician; ISBN: 0-239-23635-0
- Title: Dynamic InterWeb Programming; ISBN: 22-99521-453-1
- Welcome to Rock's Book Store
- To make a selection enter the number and press enter
- 1: Print a list of books
- 2: Print a list of books and ISBN numbers
- 3: To see if a book in store
- 4: To update the number of copies of a book
- 5: To print books data
- 9: Exit the program.
- 3
- Enter
- 1: To search the book by ISBN
- 2: To search the book by title
- 1
- Enter the ISBN of the book.
- 0-239-23635-0
- The store sells this book.
- Welcome to Rock's Book Store
- To make a selection enter the number and press enter
- 1: Print a list of books
- 2: Print a list of books and ISBN numbers
- 3: To see if a book in store
- 4: To update the number of copies of a book
- 5: To print books data
- 9: Exit the program.
- 4
- Enter
- 1: To search the book by ISBN
- 2: To search the book by title
- 2
- Enter the title of the book.
- Dynamic InterWeb Programming
- Enter the number of books 4
- Welcome to Rock's Book Store
- To make a selection enter the number and press enter
- 1: Print a list of books
- 2: Print a list of books and ISBN numbers
- 3: To see if a book in store
- 4: To update the number of copies of a book
- 5: To print books data
- 9: Exit the program.
- 5
- Title: C++Programing: From Problem Analysis to Program Design
- ISBN: 5-17-525281-3
- Publisher: ABC
- Year of Publication: 2000
- Number of Authors: 1
- Authors: Malik, D.S.;
- Price: 52.5
- Quantities in stock: 20
- ---------------------------------
- Title: Fuzzy Discrete Structures
- ISBN: 3-7908-1335-4
- Publisher: Physica-Verlag
- Year of Publication: 2000
- Number of Authors: 2
- Authors: Malik, Davender; Mordeson, John;
- Price: 89
- Quantities in stock: 10
- ---------------------------------
- Title: Fuzzy Mathematic in Medicine
- ISBN: 3-7908-1325-7
- Publisher: Physica-Verlag
- Year of Publication: 2000
- Number of Authors: 3
- Authors: Mordeson, John; Malik, Davender; Cheng, Shih-Chung;
- Price: 89
- Quantities in stock: 10
- ---------------------------------
- Title: Harry John and The Magician
- ISBN: 0-239-23635-0
- Publisher: McArthur A. Devine Books
- Year of Publication: 1999
- Number of Authors: 3
- Authors: Goof, Goofy; Pluto, Peter; Head, Mark;
- Price: 19.95
- Quantities in stock: 10
- ---------------------------------
- Title: Dynamic InterWeb Programming
- ISBN: 22-99521-453-1
- Publisher: GNet
- Year of Publication: 1998
- Number of Authors: 1
- Authors: Goof, Goofy;
- Price: 39.99
- Quantities in stock: 29
- ---------------------------------
- Welcome to Rock's Book Store
- To make a selection enter the number and press enter
- 1: Print a list of books
- 2: Print a list of books and ISBN numbers
- 3: To see if a book in store
- 4: To update the number of copies of a book
- 5: To print books data
- 9: Exit the program.
- 9
- --------------------------------
- Process exited with return value 0
- Press any key to continue . . .
- RAW Paste Data
- Pseudo code for Programming Project 5 – Due 3/21/2019
- This project involves completing Programming Exercise 12 at the end of chapter 10.
- A. Add an include for the following bookType header :
- class bookType
- {
- public:
- void setBookInfo(string title, string ISBN,
- string Publisher, int PublishYear,
- string auth[], double cost, int copies,
- int noAuthors);
- void setBookTitle(string s);
- void setBookISBN(string s);
- void setBookPrice(double cost);
- void setCopiesInStock(int noOfCopies);
- void printInfo() const;
- bool isISBN(string s) const;
- bool isTitle(string s) const;
- bool isAuthor(string s) const;
- void getBookTitle(string& s) const;
- void getBookISBN(string& s) const;
- double getBookPrice() const;
- bool isInStock() const;
- void makeSale();
- void printBookPrice() const;
- void printbookTitle() const;
- void printbookTitleAndISBN() const;
- void showQuantityInStock() const;
- void updateQuantity(int addBooks);
- bookType();
- private:
- string bookTitle;
- string bookISBN;
- string bookPublisher;
- int bookPublishYear;
- string authors[4];
- double price;
- int quantity;
- int noOfAuthors;
- };
- B. Declare the following prototypes :
- void getBookData(bookType books[], int& noOfBooks);
- void printBookData(bookType books[], int noOfBooks);
- void searchBookData(bookType books[], int bookCount);
- void searchBookDataByISBN(bookType books[], int bookCount, string ISBN,
- int& loc);
- void searchBookDataByTitle(bookType books[], int bookCount, string title,
- int& loc);
- void updateCopiesInStock(bookType books[], int bookCount);
- plus two more :
- 1. One to show the main menu
- 2. One to show the submenu
- C. In the mainline :
- Declare an array to store up to 100 books. The array will be of the type
- bookType.
- Declare an int variable to store the number of books in the array.
- Declare an int variable to store the user’s choice when they use the menu
- Set manipulators so the prices are outputted with 2 decimal positions.
- Call the getBookData function
- Call the showMenu function
- Accept the user’s choice
- While user’s choice not equal 9:
- Use a switch structure to interrogate the value of choice. There are 5 cases
- which correspond to the menu and the default case:
- For case 1: Write the code to loop through the books array. For each
- element in the array, invoke the class member function
- printbookTitle().
- For case 2: Write the code to loop through the books array. For each
- element in the array, invoke the class member function
- printbookTitleAndISBN().
- For cases 3, 4 and 5: Call the appropriate function
- Call the showMenu function
- Accept the user’s choice
- End program.
- D. After the mainline :
- Define the non-class member functions called within the mainline.
- 1. getBookData function :
- void getBookData(bookType books[], int& noOfBooks)
- {
- string title;
- string ISBN;
- string Publisher;
- int PublishYear;
- string auth[4];
- double cost;
- int copies;
- int authorCount;
- int i, j;
- - Declare an input file called infile.
- - Open the input file and verify it is opened successfully. If not, terminate
- the program.
- char ch;
- infile >> noOfBooks;
- infile.get(ch);
- for (i = 0; i < noOfBooks; i++)
- {
- getline(infile, title);
- getline(infile,ISBN);
- getline(infile,Publisher);
- infile >> PublishYear >> cost >> copies >> authorCount;
- infile.get(ch);
- for (j = 0; j < authorCount; j++)
- getline(infile, auth[j]);
- books[i].setBookInfo(title, ISBN, Publisher,
- PublishYear, auth, cost, copies,
- authorCount);
- }
- }
- 2. searchBookData function :
- void searchBookData(bookType books[], int bookCount)
- {
- int choice;
- char ch;
- int loc;
- string str;
- Call the submenu function
- Accept user’s choice
- Use a switch structure to interrogate the value of choice. There are 3 cases
- which correspond to the menu and the default case:
- For case 1: Prompt and accept ISBN
- Call searchBookDataByISBN
- If loc not equal to -1 state that the store sells the book.
- Otherwise, state the store does not.
- For case 2: Prompt and accept Book Title
- Call searchBookDataByTitle
- If loc not equal to -1 state that the store sells the book.
- Otherwise, state the store does not.
- 3. searchBookDataByISBN function :
- This is the code to locate the index of the books array where the ISBN is found :
- {
- int i;
- loc = -1;
- for (i = 0; i < bookCount; i++)
- if (books[i].isISBN(ISBN))
- {
- loc = i;
- break;
- }
- }
- 4. searchBookDataByTile function : Model code after searchBookDataByISBN
- function
- 5. updateCopiesInStock function
- {
- int choice;
- int loc;
- int count;
- char ch;
- string str;
- Call the submenu function
- Accept user’s choice
- Use a switch structure to interrogate the value of choice. There are 3 cases
- which correspond to the menu and the default case:
- For case 1: Prompt and accept ISBN
- Call searchBookDataByISBN
- If loc not equal to -1
- prompt and accept number of books
- call the class member function updateQuantitiy.
- Otherwise, state the store does not sell book.
- For case 2: Prompt and accept Book Title
- Call searchBookDataByTitle
- If loc not equal to -1
- prompt and accept number of books
- call the class member function updateQuantitiy.
- Otherwise, state the store does not sell book.
- 6. printBookData function :
- Write the code to loop through the books array. For each element in the
- array, invoke the class member function printInfo(). See the sample execution
- below for the output
- 7. showMenu function :
- Outputs :
- Welcome to Rock's Book Store
- To make a selection enter the number and press enter
- 1: Print a list of books
- 2: Print a list of books and ISBN numbers
- 3: To see if a book in store
- 4: To update the number of copies of a book
- 5: To print books data
- 9: Exit the program.
- 8. subMenu function :
- Outputs :
- Enter
- 1: To search the book by ISBN
- 2: To search the book by title
- E. Implementation File :
- Define the class member functions :
- void bookType::setBookInfo(string title, string ISBN,
- string Publisher, int PublishYear,
- string auth[], double cost, int copies,
- int authorCount)
- {
- Set all the private class members to parmeters. Note that there can be up to
- 4 authors per book.
- }
- void bookType::setBookTitle(string s)
- {
- bookTitle = s;
- }
- setBookISBN : Follow setBookTitle function definition
- setBookPrice : Follow setBookTitle function definition
- setCopiesInStock : Follow setBookTitle function definition
- printInfo: Output the contents of the private variables per execution
- example. For instance :
- Title: C++Programing: From Problem Analysis to Program Design
- ISBN: 5-17-525281-3
- Publisher: ABC
- Year of Publication: 2000
- Number of Authors: 1
- Authors: Malik, D.S.;
- Price: 52.5
- Quantities in stock: 20
- bool bookType::isISBN(string s) const
- {
- return (bookISBN == s);
- }
- isTitle Follow bookType::isISBN function definition
- bool bookType::isAuthor(string s) const
- {
- bool found = false;
- int i;
- for (i = 0; i < noOfAuthors; i++)
- if (authors[i] == s)
- {
- found = true;
- break;
- }
- return found;
- }
- void bookType::getBookTitle(string& s) const
- {
- s = bookTitle;
- }
- getBookISBN Follow getBookTitle function definition
- double bookType::getBookPrice() const
- {
- return price;
- }
- bool bookType::isInStock() const
- {
- return (quantity > 0);
- }
- void bookType::makeSale()
- {
- quantity--;
- }
- void bookType::printBookPrice() const
- {
- cout << "Price = " << price << endl;
- }
- printbookTitle Follow printBookPrice function definition
- printbookTitleAndISBN Follow printBookPrice function definition
- showQuantityInStock Follow printBookPrice function definition
- void bookType::updateQuantity(int addBooks)
- {
- quantity = quantity + addBooks;
- }
- bookType::bookType()
- {
- int i;
- bookTitle = "";
- bookISBN = "";
- bookPublisher = "";
- bookPublishYear = 1900;
- noOfAuthors = 0;
- for (i = 0; i < 4; i++)
- authors[i] = "";
- price = 0;
- quantity = 0;
- }
- (See next page for a sample execution)
- F. Sample execution :
- Welcome to Rock's Book Store
- To make a selection enter the number and press enter
- 1: Print a list of books
- 2: Print a list of books and ISBN numbers
- 3: To see if a book in store
- 4: To update the number of copies of a book
- 5: To print books data
- 9: Exit the program.
- 2
- Title: C++Programing: From Problem Analysis to Program Design; ISBN: 5-17-525281-3
- Title: Fuzzy Discrete Structures; ISBN: 3-7908-1335-4
- Title: Fuzzy Mathematic in Medicine; ISBN: 3-7908-1325-7
- Title: Harry John and The Magician; ISBN: 0-239-23635-0
- Title: Dynamic InterWeb Programming; ISBN: 22-99521-453-1
- Welcome to Rock's Book Store
- To make a selection enter the number and press enter
- 1: Print a list of books
- 2: Print a list of books and ISBN numbers
- 3: To see if a book in store
- 4: To update the number of copies of a book
- 5: To print books data
- 9: Exit the program.
- 3
- Enter
- 1: To search the book by ISBN
- 2: To search the book by title
- 1
- Enter the ISBN of the book.
- 0-239-23635-0
- The store sells this book.
- Welcome to Rock's Book Store
- To make a selection enter the number and press enter
- 1: Print a list of books
- 2: Print a list of books and ISBN numbers
- 3: To see if a book in store
- 4: To update the number of copies of a book
- 5: To print books data
- 9: Exit the program.
- 4
- Enter
- 1: To search the book by ISBN
- 2: To search the book by title
- 2
- Enter the title of the book.
- Dynamic InterWeb Programming
- Enter the number of books 4
- Welcome to Rock's Book Store
- To make a selection enter the number and press enter
- 1: Print a list of books
- 2: Print a list of books and ISBN numbers
- 3: To see if a book in store
- 4: To update the number of copies of a book
- 5: To print books data
- 9: Exit the program.
- 5
- Title: C++Programing: From Problem Analysis to Program Design
- ISBN: 5-17-525281-3
- Publisher: ABC
- Year of Publication: 2000
- Number of Authors: 1
- Authors: Malik, D.S.;
- Price: 52.5
- Quantities in stock: 20
- ---------------------------------
- Title: Fuzzy Discrete Structures
- ISBN: 3-7908-1335-4
- Publisher: Physica-Verlag
- Year of Publication: 2000
- Number of Authors: 2
- Authors: Malik, Davender; Mordeson, John;
- Price: 89
- Quantities in stock: 10
- ---------------------------------
- Title: Fuzzy Mathematic in Medicine
- ISBN: 3-7908-1325-7
- Publisher: Physica-Verlag
- Year of Publication: 2000
- Number of Authors: 3
- Authors: Mordeson, John; Malik, Davender; Cheng, Shih-Chung;
- Price: 89
- Quantities in stock: 10
- ---------------------------------
- Title: Harry John and The Magician
- ISBN: 0-239-23635-0
- Publisher: McArthur A. Devine Books
- Year of Publication: 1999
- Number of Authors: 3
- Authors: Goof, Goofy; Pluto, Peter; Head, Mark;
- Price: 19.95
- Quantities in stock: 10
- ---------------------------------
- Title: Dynamic InterWeb Programming
- ISBN: 22-99521-453-1
- Publisher: GNet
- Year of Publication: 1998
- Number of Authors: 1
- Authors: Goof, Goofy;
- Price: 39.99
- Quantities in stock: 29
- ---------------------------------
- Welcome to Rock's Book Store
- To make a selection enter the number and press enter
- 1: Print a list of books
- 2: Print a list of books and ISBN numbers
- 3: To see if a book in store
- 4: To update the number of copies of a book
- 5: To print books data
- 9: Exit the program.
- 9
- --------------------------------
- Process exited with return value 0
- Press any key to continue . . .
- create new paste / dealsnew! / syntax languages / archive / faq / tools / night mode / api / scraping api / go
- privacy statement / cookies policy / terms of service / security disclosure / dmca / contact
- By using Pastebin.com you agree to our cookies policy to enhance your experience.
- Site design & logo © 2018 Pastebin; user contributions (pastes) licensed under cc by-sa 3.0 -- Dedicated Server Hosting by Steadfast Top
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement