Assignment 5 Problem: You are to modify the Serendipity Booksellers software pac
ID: 3635993 • Letter: A
Question
Assignment 5Problem:
You are to modify the Serendipity Booksellers software package to include arrays or vectors, record the inventory to a file, implement reports, and write a receipt to a file.
1. Add Global Arrays to hold up to 20 items in your program.
const int SIZE = 20;
int numBooks = 0; // number of books to start
string date; //YYYY/MM/DD current date for receipts and reports
• bookTitle: A one-dimensional array of strings.
• isbn: A one-dimensional array of strings.
• author: A one-dimensional array of strings.
• publisher: A one-dimensional array of strings.
• dateAdded: A one-dimensional array of strings. The dates should be stored in the form YYYY/MM/DD. For example, April 2, 2009 would be stored as 2009/04/02.
• qtyOnHand: A one-dimensional array of ints. This holds the quantity on hand of each book in the inventory.
• wholesale: A one-dimensional array of doubles. This holds the wholesale price of each book in the inventory.
• retail: A one-dimensional array of doubles. This holds the retail price of each book in the inventory.
2. Understand the Relationship Between the Arrays.
The data stored in the arrays will be linked through their subscripts. The string stored in bookTitle[0] is the title of the book whose ISBN number is stored in isbn[0]. Likewise, the data stored in author[0], publisher[0], dateAdded[0], qtyOnHand[0], wholesale[0], and retail[0] also belong to the same book.
3. Modify the bookInfo Function
void bookInfo(int index);
The bookInfo function currently displays the following screen:
Serendipity Booksellers
Book Information
ISBN:
Title:
Author:
Publisher:
Date Added:
Quantity-On-Hand:
Wholesale Cost:
Retail Price:
Modify the function so it has the following parameters:
• int index
The program should display the data passed into its parameters in the following format:
Serendipity Booksellers
Book Information
ISBN: 1-999111-22-1
Title: Robert the Bruce, King of Scotland
Author: Haynes, Timothy
Publisher: Historical Publishers, Inc.
Date Added: 2009/04/02
Quantity-On-Hand: 20
Wholesale Cost: 15.50
Retail Price: 19.95
Add Searching capabilities to the addBook, lookUpBook, editBook, and deleteBook functions.
4. Modify the addBook Function
When a new book is added to the inventory, the program will see if numBooks is less than the constant SIZE. If they are equal then report that there is no more room to add books. Otherwise, read the data into the arrays at index numBooks. Have this function call bookInfo( numBooks) to display the information added. Finally, add one to the number of books in the inventory.
5. Modify 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 a 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 index as the argument.
• Allow the index to be passed back to the calling routine so it can be used by the cashier module. int lookUpBook();
6. Modify 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 a 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 index as the argument.
• The function should ask the user which of the fields he or she wishes 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.
7. Modify 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 a 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 index as the argument.
• The function should ask the user if they are sure the book’s data are to be deleted from the inventory. If so, then move the book located at numBooks – 1 into the index of the book to be deleted and reduce the numBooks by 1.
8. Allow Multiple Transactions
Currently the cashier function only calculates the sale of one title. Modify it so that multiple titles may be purchased. After the data for each book is entered, the function should ask if there are other titles being purchased. If so it allows the user to enter the data for another book. If not, it calculates the sale subtotal, tax, and total.
You may want to write out the receipt to a file so that the input questions do not interfere with the cashier questions to the user. You can declare a file stream, open it, write to it and then close it.
ofstream receipt;
receipt.open(“receipt.txt”);
9. Enable Automatic Lookup
The cashier function currently asks the user to enter the title, ISBN number, and price of the book being purchased. Modify the function so that once the user only has to enter the title, it returns the index and then you have access to the book isbn, price and quantity on hand.
If the function cannot locate the title in thebookTitle array, it should display a message indicating so.
Once a book’s data has been retrieved, the function should check the QtyOnHand array to determine whether there are enough copies in stock to fill the order. If so, the function should subtract the number of copies being purchased from the amount in the array. If there aren’t enough copies in stock, the function should display a message indicating so and then return to the main menu.
10. Complete the Stub Functions Called from the Reports Menu.
Currently, when the user chooses an option from the Reports menu, a stub function is called, indicating which option was chosen. Modify the stub functions so they actually display the correct report on the screen.
The repListing function should display a report listing all the books in the inventory. The following data should be included in the report: title, ISBN number, author, publisher, date added to inventory, quantity on hand, wholesale cost, and retail price. The report should display an appropriate title that includes the global date. The function should fill the screen with data and then ask the user to press a key to continue to the next screen. You can use system(“pause”);
The repWholesale function should display a report that lists the following data on all books in the inventory: title, ISBN number, quantity on hand, and wholesale cost. The report should display an appropriate title that includes the date. The function should fill the screen with data and then ask the user to press a key to continue to the next screen. The last line of the report should give the total wholesale value of the inventory (the sum of each book’s wholesale cost multiplied by the quantity on hand). The function should fill the screen with data and then ask the user to press a key to continue to the next screen. You can use system(“pause”);
The repRetail function should display a report that lists the following data on all books in the inventory: title, ISBN number, quantity on hand, and retail price. The report should display an appropriate title that includes the date. The function should fill the screen with data and then ask the user to press a key to continue to the next screen. The last line of the report should give the total retail value of the inventory (the sum of each book’s retail price multiplied by the quantity on hand). The function should fill the screen with data and then ask the user to press a key to continue to the next screen. You can use system(“pause”);
The repQty function should display a report that lists the following data on all books in the inventory: title, ISBN number, and quantity on hand. The list should be sorted by quantity on hand in descending order (the books of the greatest quantity listed first). Remember to copy the 3 arrays into temporary arrays and then sort these temporary arrays. The report should display an appropriate title that includes the date. The function should fill the screen with data and then ask the user to press a key to continue to the next screen. You can use system(“pause”);
The repCost function should display a report that lists the following data on all books in the inventory: title, ISBN number, quantity on hand and wholesale cost. The list should be sorted by wholesale cost in descending order (the books of the greatest unit cost listed first). Remember to copy the 4 arrays into temporary arrays and then sort these temporary arrays. The report should display an appropriate title that includes the date. The function should fill the screen with data and then ask the user to press a key to continue to the next screen. You can use system(“pause”);
The repAge function should display a report that lists the following data on all books in the inventory: title, ISBN number, quantity on hand, and date added to the inventory. The list should be sorted by date added in descending order (the books that have been in inventory longest will be listed first). Remember to copy the 4 arrays into temporary arrays and then sort these temporary arrays. The report should display an appropriate title that includes the date. The function should fill the screen with data and then ask the user to press a key to continue to the next screen. You can use system(“pause”);
11. You are to add files to your project to make testing and running your program easier. This can be done using the following functions to your program.
void getData()
{ int index =0;
ifstream data;
data.open("inventory.txt");
if (data.fail())
{
cout << "There are currently no books in the Inventory. ";
}
else
{ getline(data,isbn[index]);
while (!data.eof() && index < SIZE)
{
getline(data,bookTitle[index]);
getline(data,author[index]);
getline(data,publisher[index]);
data >> dateAdded[index];
data >>qtyOnHand[index];
data>> wholesale[index];
data>> retail[index];
data.ignore(100,' ');
bookinfo(index);
index++;
if (index == SIZE)
cout << "Inventory tables are full, no more can be added. ";
else
getline(data,isbn[index]);
}
numBooks = index;
cout << "Inventory has been added. There are currently " << index << " book titles. ";
data.close();
}
}
void saveData()
{ int index =0;
int count =0;
ofstream data;
data.open("inventory.txt");
if (!data)
{ cout << "There is a problem writing to the Inventory file. ";
}
else
{ for (index = 0; index < numBooks; index++)
data << isbn[index] << " "<< bookTitle[index] << " " << author[index]<< " "
<< publisher[index] << " " <<dateAdded[index]<< " " <<qtyOnHand[index]
<< " " << wholesale[index] << " "<<retail[index] << endl; }
cout << "Inventory has been saved. There are currently " << numBooks << " book titles. ";
data.close();
}
The inventory.txt file could look like this to start:
0-333-90123-8
History of Scotland
John Donne
Addison Wesley
2007/04/12
13
10.95
19.95
0-444-93212-4
All's Well That Ends Well
William Shakespeare
Prentice Hall
2007/03/06
15
12.5
21.95
0-555-90154-8
War and Peace
Leo Tolstoy
Penguin Books
2008/01/11
10
24.9
45.5
A Sample session using getData() and saveDat() may run as follows:
Please enter today's date:2008/ 04/11
Serendipity Booksellers
Book Information
ISBN: 0-333-90123-8
Title: History of Scotland
Author: John Donne
Publisher: Addison Wesley
Date Added: 2007/04/12
Quantity-On-Hand: 11
Wholesale Cost: 10.95
Retail Price: 19.95
Serendipity Booksellers
Book Information
ISBN: 0-444-93212-4
Title: All's Well That Ends Well
Author: William Shakespeare
Publisher: Prentice Hall
Date Added: 2007/03/06
Quantity-On-Hand: 13
Wholesale Cost: 12.50
Retail Price: 21.95
Serendipity Booksellers
Book Information
ISBN: 0-555-90154-8
Title: War and Peace
Author: Leo Tolstoy
Publisher: Penguin Books
Date Added: 2008/01/11
Quantity-On-Hand: 9
Wholesale Cost: 24.90
Retail Price: 45.50
Inventory has been added. There are currently 3 book titles.
Sample Screen shot for Cashier Module:
Serendipity Booksellers
Main Menu
1. Cashier Module
2. Inventory Database Module
3. Report Module
4. Exit
Enter Your Choice: 1
You have selected The Cashier Module
Enter the title: History of Scotland
Quantity of Book: 1
ISBN: 0-333-90123-8
The price of the book is: 19.95
Do you wish to process another transaction? Y/N: y
Enter the title: All's Well That Ends Well
Quantity of Book: 1
ISBN: 0-444-93212-4
The price of the book is: 21.95
Do you wish to process another transaction? Y/N: y
Enter the title: War and Peace
Quantity of Book: 2
ISBN: 0-555-90154-8
The price of the book is: 45.50
Do you wish to process another transaction? Y/N: n
Your receipt is being printed.
The receipt.txt file would look like:
Serendipity Booksellers
Cashier Module
Date: 2008/04/11
Qty ISBN Title Price Total
_____________________________________________________________________________
1 0-333-90123-8 History of Scotland 19.95 19.95
1 0-444-93212-4 All's Well That Ends Well 21.95 21.95
2 0-555-90154-8 War and Peace 45.50 91.00
Subtotal 132.90
Tax 7.97
Total 140.87
Thank you for shopping at Serendipity.
Thank you for shopping at Serendipity.
Serendipity Booksellers
Main Menu
1. Cashier Module
2. Inventory Database Module
3. Report Module
4. Exit
Enter Your Choice: 4
What to hand in:
1. You are to hand in well documented source code and the files for the following:
mainmenu.cpp
mainmenu.h
inventory.txt
receipt.txt
2. Test your program for all functions. Hand in screen shots.
3. Please hand in a user’s guide. (Purpose, Sample session, Assumptions/Limitations)
4. Please hand in a hierarchy chart showing the mainmenu on top and the 4 choices as boxes underneath. Then show the choices the user can enter for each of the choices above.
Explanation / Answer
Hi I have done the solution for this in my notebook. But the solution is too big , I cannot type it here because very less time is remaining.. So please rate me Lifesaver and I'll share the answer with you through email or cramster inbox. I don't do this generally, but I have no other option here because there's very less time left... you need not worry as I have the solution ready