Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Complete the addBook function When a new book is added to the inventory, the program will search the bookTitle array for an element that

1. Complete the addBook function

When a new book is added to the inventory, the program will search the bookTitle array for an element that is set to an empty string or the null terminator. If the element contains an empty string or a null terminator, it means there isnt a string stored there. (Because the arrays are global, all their elements will be automatically initialized to zero.)

Once an empty element is found in the bookTitle array, the books data may be stored in each of the other arrays by using the same subscript. For instance, if the title of the book is stored in bookTitle[7], its ISBN number will be stored in isbn[7], its authors name will be stored in author[7], its publishers name will be stored in publisher[7], the date the book was added to the inventory will be stored in dateAdded[7], the quantity of books on hand will be stored in qtyOnHand[7], the books wholesale price will be stored in wholesale[7], and the books retail price will be stored in retail[7].

The addBook function is currently a stub function. Modify it so it performs the following steps:

First the function should search the bookTitle array for an empty element. As described above, the function should look for an element containing an empty string or the null terminator. If no empty element is found, it means the array is full. In that case, the function should display a message indicating that no more books may be added to the inventory, and then terminate.

Once an empty element is found in bookTitle, the function should ask the user to enter the following items:

Book title

ISBN number

Authors name

Publishers name

The date the book was added to the inventory

The quantity of the book being added

The wholesale cost of the book

The retail price of the book

Each item above should be added to the appropriate array. Note that the wholesale cost and retail price is for a single copy of the book. Also, remember that the date should be entered in the form MM-DD-YYYY, where MM is the month, DD is the day, and YYYY is the year.

Test your code with below information.

ISBN: 1-999111-22-1

Title: Robert the Bruce, King of Scotland

Author: Haynes, Timothy

Publisher: Historical Publishers, Inc.

Date Added: 04-02-2012

Quantity-On-Hand: 20

Wholesale Cost: 15.50

Retail Price: 19.95

image text in transcribed

image text in transcribed

2. Complete the lookUpBook Function

The lookUpBook function is currently a stub function. Modify it so it performs the following tasks:

It should ask the user for the title of a book. This is the book that is to be looked up in the inventory database.

The function should search the bookTitle array for a title that matches the one entered by the user. If no match is found, the function should display a message indicating that the book is not in inventory, and terminate. If the book is found, the function should call bookInfo, passing the correct data as arguments.

3. Complete the editBook Function

The editBook function is currently a stub function. Modify it so it performs the following tasks:

It should ask the user for the title of a book. This is the book whose data are to be edited.

The function should search the bookTitle array for a title that matches the one entered by the user. If no match is found, the function should display a message indicating that the book is not in inventory, and terminate. If the book is found, the function should call bookInfo, passing the correct data as arguments.

The function should ask the user which of the fields he or she wished to change. The user is then allowed to enter new values for the selected field. These new values are saved in the arrays, replacing the old values

image text in transcribed

4. Complete the deleteBook Function

The deleteBook function is currently a stub function. Modify it so it performs the following

tasks:

It should ask the user for the title of a book. This is the book that is to be deleted from the inventory database.

The function should search the bookTitle array for a title that matches the one entered by the user. If no match is found, the function should display a message indicating that the book is not in inventory, and terminate. If the book is found, the function should call bookInfo, passing the correct data as arguments.

The function should ask the user if they are sure the books data are to be deleted from the inventory. If so, the books title (stored in the bookTitle array) is to be set to an empty string or the null terminator. The ISBN number (stored in the isbn array) should be set to an empty string or the null terminator as well.

image text in transcribed

 #include  #include  #include  using namespace std; // Function Prototypes void cashier(); void invMenu(); void bookInfo(string, string, string, string, string, int, double, double); void lookUpBook(); void addBook(); void editBook(); void deleteBook(); // Constant for array sizes const int SIZE = 1; // Global Arrays string bookTitle[SIZE]; string isbn[SIZE]; string author[SIZE]; string publisher[SIZE]; string dateAdded[SIZE]; int qtyOnHand[SIZE]; double wholesale[SIZE]; double retail[SIZE]; int main() { int choice = 0; // To hold the user's menu choice // Display the menu until the user selects item 4 while (choice != 2) { cout > choice; // Validate the user's input while (choice  2) { cout > choice; } // Display the selection { switch (choice) { case 1: invMenu(); break; case 2: cout > choice; // Validate the user's input while (choice  5) { cout > choice; } // Display the selection { switch (choice) { case 1: lookUpBook(); break; case 2: addBook(); break; case 3: editBook(); break; case 4: deleteBook(); break; case 5: cout   CAUsersleleel DesktoplCPSC230-Testi Debug1CPSC230.exe Serendipity Booksellers Inventory Database 1.Look Up a Boolk 2.Add a Book 3.Edit a Book's Record 4.Delete a Book 5.Return to the Main Menu Enter Your Choice: 2 Enter Title: Robert the Bruce. King of Scotland Enter Author: Haynes. Timothy Enter Publisher: Historical Publishers. Inc. Enter Date Added to Inventory ?MM/DD/YYYY): 04/02/2012 Enter Quantity Being Added: 20 Enter Wholesale Cost: 15.50 Enter Retail Price: 19.95 Record was successfully entered. Serendipity Booksellers Inventory Database ?Look Up a Book 2.Add a Book 3.Edit a Book's Record 4.Delete a Book 5.Return to the Main Menu Enter Your Choice: 5 ou selected item 5 Serendipity Booksellers Main Menu 1.Inuentory Database Module 2.Exit Enter Your Choice:  CAUsersleleel DesktoplCPSC230-Testi Debug1CPSC230.exe Serendipity Booksellers Inventory Database 1.Look Up a Boolk 2.Add a Book 3.Edit a Book's Record 4.Delete a Book 5.Return to the Main Menu Enter Your Choice: 2 Enter Title: Robert the Bruce. King of Scotland Enter Author: Haynes. Timothy Enter Publisher: Historical Publishers. Inc. Enter Date Added to Inventory ?MM/DD/YYYY): 04/02/2012 Enter Quantity Being Added: 20 Enter Wholesale Cost: 15.50 Enter Retail Price: 19.95 Record was successfully entered. Serendipity Booksellers Inventory Database ?Look Up a Book 2.Add a Book 3.Edit a Book's Record 4.Delete a Book 5.Return to the Main Menu Enter Your Choice: 5 ou selected item 5 Serendipity Booksellers Main Menu 1.Inuentory Database Module 2.Exit Enter Your Choice

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions