Question

using the source code at the bottom of this page, use the following instructions to make...

using the source code at the bottom of this page, use the following instructions to make the appropriate modifications to the source code.

Serendipity Booksellers Software Development

Project— Part 7: A Problem-Solving Exercise

For this chapter’s assignment, you are to add a series of arrays to the program. For the time being, these arrays will be used to hold the data in the inventory database. The functions that allow the user to add, change, and delete books in the store’s inventory will modify the data held in these arrays.

NOTE: The arrays you add in this chapter will only be large enough to hold data for 20 books. These arrays will primarily be used for testing the functions you are writing. In Chapter 12 you will modify the program to store this data in a file. At that time the program will be able to keep an inventory as large as the disk will hold.

Understand the Relationship Between the Arrays

Add the following global arrays to the program:

bookTitle:     An array of string objects that will hold the title of each book in the inventory.

isbn:     An array of string objects that will hold the ISBN number of each book in the inventory.

author:     An array of string objects that will hold the name of the author of each book in the inventory.

publisher:     An array of string objects that will hold the name of the publisher of each book in the inventory.

dateAdded:     An array of string objects that will hold the date each book was added to the inventory. The dates should be stored in the form MM-DD-YYYY. For example, April 2, 2012 would be stored as 04-02-2012.

qtyOnHand:     An array of ints that will hold the quantity on hand of each book in the inventory.

wholesale:     An array of doubles that will hold the wholesale price of each book in the inventory.

retail:     An array of doubles that will hold the retail price of each book in the inventory.

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 that same book.

Modify the bookInfo Function

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:

isbn:     a string object. The ISBN number of a book will be passed into this parameter.

title:     a string object. The book title will be passed into this parameter.

author:     a string object. The author’s name will be passed into this parameter.

publisher:     a string object. The publisher’s name will be passed into this parameter.

date:     a string object. The date the book was added to inventory will be passed into this parameter.

qty:     an integer. The quantity on hand of the book will be passed into this parameter.

wholesale:     a double. The wholesale cost of the book will be passed into this parameter.

retail:     a double. The retail price of the book will be passed into this parameter.

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: 04-02-2012

Quantity-On-Hand: 20

Wholesale Cost: 15.50

Retail Price: 19.95

Here is the source code:

mainmenu.h

//functions used in the main function required for each menu option
int reports(); //to report
int booksInfo(); //gives books info
int cashier(); //to calculate the price
int invMenu(); //to perform inventory options

//stub functions for inventory
void lookUpBook(); //to lookUp book
void addBook(); //to add book
void editBook(); //to edit book
void deleteBook(); //to delete book

//Stub functions for reporting
void repListing(); //to list books in inventory
void repWholesale(); //to report wholesale value
void repRetail(); //to report retail value
void repQty(); //to report quantity
void repCost(); //to report cost
void repAge(); //to report age

mainmenu.cpp

#include <iostream>

#include <string>
#include <iomanip>

#include "mainmenu.h"
using namespace std;

int main()
{
int choice = 0, ret;
while(choice!=4)
{
cout<<"\n\t Serendipity Booksellers" <<endl;
cout<<"\t Main Menu"<<endl <<endl;
cout<<"\t 1. Cashier Module" <<endl;
cout<<"\t 2. Inventory Database Module" <<endl;
cout<<"\t 3. Report Module" <<endl;
cout<<"\t 4. Exit" << endl;
cout<<"\t Enter Your Choice: ";
  
while(1)
{
cin>>choice;
if(choice<1 || choice>4)
{
cout<<"\t Please enter a number in the range 1 - 4."<<endl;
cout<<"\t Enter Your Choice: ";
}
else
break;
}
switch(choice)
{
case 1:
ret=cashier(); //cashier function is called
break;
case 2:
ret=invMenu(); //invMenu function is called
break;
case 3:
ret=reports(); //reports function is called
break;
case 4:
cout<<"\t You selected item 4";
break;
}
}
return 0;
}

//function bookInfo displays the information of book
int bookInfo()
{

cout<<"\t Serendipity Booksellers" <<endl;
cout<<"\t Book Information"<<endl <<endl;
cout<<"ISBN:" <<endl;
cout<<"Author:" <<endl;
cout<<"Publisher:" <<endl;
cout<<"Date Added:" << endl;
cout<<"Quantity-On-Hand:" <<endl;
cout<<"Wholesale Cost:"<<endl;
cout<<"Retail Price:" <<endl <<endl;
return 0;
}

//function inventory menu to display the inventory menu options
int invMenu()
{
int choice = 0;
while(choice!=5)
{
cout<<"\n\t Serendipity Booksellers" <<endl;
cout<<"\t Inventory Database"<<endl <<endl;
cout<<"\t 1. Look Up a Book" <<endl;
cout<<"\t 2. Add a Book" <<endl;
cout<<"\t 3. Edit a Book's Record" <<endl;
cout<<"\t 4. Delete a Book" << endl;
cout<<"\t 5. Return to the Main Menu"<<endl <<endl;
cout<<"\t Enter Your Choice: ";
  

while(1)
{
cin>>choice;
if(choice<1 || choice>5)
{
cout<<"\t Please enter a number in the range 1 - 5."<<endl;
cout<<"\t Enter Your Choice: ";
}
else
break;
}
  
switch(choice)
{
case 1:
lookUpBook(); //call the lookupBook function
break;
case 2:
addBook(); //call the addBook function
break;
case 3:
editBook(); //call the editBook function
break;
case 4:
deleteBook(); //call the deleteBook function
break;
case 5:
cout<<"\t You selected item 5";
break;
}
}
return 0;
}

int reports()
{
int choice = 0;
while(choice!=7)
{
cout<<"\n\t Serendipity Booksellers" <<endl;
cout<<"\t Reports"<<endl <<endl;
cout<<"\t 1. Inventory Listing" <<endl;
cout<<"\t 2. Inventory Wholesale Value" <<endl;
cout<<"\t 3. Inventory Retail Value" <<endl;
cout<<"\t 4. Listing by Quantity " << endl;
cout<<"\t 5. Listing by Cost " << endl;
cout<<"\t 6. Listing by Age " <<endl;
cout<<"\t 7. Return To Main Menu:"<<endl <<endl;
cout<<"\t Enter Your Choice: ";
  
while(1)
{
cin>>choice;
if(choice<1 || choice>7)
{
cout<<"\t Please enter a number in the range 1 - 7."<<endl;
cout<<"\t Enter Your Choice: ";
}
else
break;
}
switch(choice)
{
case 1:
repListing(); //call the repListing function
break;
case 2:
repWholesale(); //call the repWholesale function
break;
case 3:
repRetail(); //call the repRetail function
break;
case 4:
repQty(); //call the repQty function
break;
case 5:
repCost(); //call the repCost() function
break;
case 6:
repAge(); //call the repAge() function
break;
case 7:
cout<<"\t You selected item 7";
break;
}
}
return 0;
}

//function cashier
int cashier()
{
string date, ISBN, Title;
int numOfBook;
double price, subtotal, tax, total;
int flag=1;
while(flag==1)
{
cout<<"\tSerendipity Booksellers"<<endl;
cout<<"Cashier Module"<<endl <<endl;
cout<< "Date (MM/DD/YY): ";
getline (cin >> ws, date);
cout<<"Quantity of Book: ";
cin >> numOfBook;
cout<< "ISBN: ";
getline (cin >> ws, ISBN);
cout<< "Title: ";
getline (cin >> ws, Title);
cout<< "Price: ";
cin >> price;
subtotal = numOfBook * price;
tax = 6 * subtotal / 100;
total = subtotal + tax;

// setting to 2 decimal places in fixed point notation
cout << fixed << setprecision(2);
cout <<endl << "Serendipity Book Sellers" <<endl;
cout<< "Date: " << date << endl << endl;
// printing the nice header
cout<< "Qty" <<setw(10) << "ISBN" << setw(17) << "Title" << setw(24)
<< "Price" << setw(11)<< "Total" << endl;
cout<< "--------------------------------------------------------------------" <<endl;
// printing the book data
cout << numOfBook << setw(21) << ISBN << setw(22) << Title << setw(18) << setfill(' ')
<< setw(6)<< "$" << price << setfill(' ') << setw(6) << "$"<< subtotal<<endl;
cout<<"\t\tSubtotal" <<setfill(' ') << setw(6) << "$"<< subtotal << endl;
cout<<"\t\tTax" << setfill(' ') << setw(6) << "$" << tax <<endl;
cout<<"Total" << " $" << total <<endl << endl;
cout<<"\n------------------------------------------";
cout<<"\n\tDo you want to continue..??(1 for Yes):";
  
cin>>flag;
cout<<"\n------------------------------------------";
}
cout<<"Thank you for shopping at Serendipity!" <<endl;

}

//Stub functions for inventory menu options
//function to lookup book
void lookUpBook()
{
cout<<"You selected Look Up Book.";
}

//function to add book
void addBook()
{
cout<<"You selected Add Book.";
}

//function to edit book
void editBook()
{
cout<<"You selected Edit Book.";
}

//function to delete book
void deleteBook()
{
cout<<"You selected Delete Book.";
}

//Stub functions for report options
//function to list books
void repListing()
{
cout<<"You selected Inventory Listing.";
}

//function to report wholesale value
void repWholesale()
{
cout<<"You selected Inventory Wholesale Value.";
}

//function to report retail value
void repRetail()
{
cout<<"You selected Inventory Retail Value.";
}

//function to report Quantity
void repQty()
{
cout<<"You selected Listing By Quantity.";
}

//function to report cost
void repCost()
{
cout<<"You selected Listing By Cost.";
}

//function to report age
void repAge()
{
cout<<"You selected Listing By Age.";
}

Output:

Serendipity Booksellers                                                                                                 

                Main Menu                                                                                                        

                                                                                                                                 

         1. Cashier Module                                                                                                       

         2. Inventory Database Module                                                                                            

         3. Report Module                                                                                                        

         4. Exit                                                                                                                 

         Enter Your Choice: 2                                                                                                    

                                                                                                                                 

         Serendipity Booksellers                                                                                                 

           Inventory Database                                                                                                    

                                                                                                                                 

         1. 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: 1

You selected Look Up Book.                                                                                                       

         Serendipity Booksellers                                                                                                 

           Inventory Database                                                                                                    

                                                                                                                                 

         1. 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                                                                                                    

         You selected item 5                                                                                                     

         Serendipity Booksellers                                                                                                 

                Main Menu                                                                                                        

                                                                                                                                 

         1. Cashier Module                                                                                                       

         2. Inventory Database Module                                                                                            

         3. Report Module                                                                                                        

         4. Exit                                                                                                                 

         Enter Your Choice: 4                                                                                                    

         You selected item 4  

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//The modified bookInfo method

//function bookInfo displays the information of book

int bookInfo(string isbn, string title, string author, string publisher, string date,

string qty, double wholesale, double retail)

{

cout << "\t Serendipity Booksellers" << endl;

cout << "\t Book Information" << endl << endl;

cout << "ISBN:" << isbn << endl;

cout << "Author:" << author << endl;

cout << "Publisher:" << publisher << endl;

cout << "Date Added:" << date << endl;

cout << "Quantity-On-Hand:" << qty << endl;

cout << "Wholesale Cost:" << wholesale << endl;

cout << "Retail Price:" << retail << endl;

return 0;

}

Add a comment
Know the answer?
Add Answer to:
using the source code at the bottom of this page, use the following instructions to make...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • my program wont run on my computer and im not understanding why. please help. #include<iostream> #include<iomanip>...

    my program wont run on my computer and im not understanding why. please help. #include<iostream> #include<iomanip> #include<string> #include "bookdata.h" #include "bookinfo.h" #include "invmenu.h" #include "reports.h" #include "cashier.h" using namespace std; const int ARRAYNUM = 20; BookData bookdata[ARRAYNUM]; int main () { bool userChoice = false; while(userChoice == false) { int userInput = 0; bool trueFalse = false; cout << "\n" << setw(45) << "Serendipity Booksellers\n" << setw(39) << "Main Menu\n\n" << "1.Cashier Module\n" << "2.Inventory Database Module\n" << "3.Report Module\n"...

  • The following is a sample inventory in C++, i want to ask the user to input a item number for removing from inventory. //CPP #include <iostream> #include <fstream> #include <cstdlib>...

    The following is a sample inventory in C++, i want to ask the user to input a item number for removing from inventory. //CPP #include <iostream> #include <fstream> #include <cstdlib> #include <iomanip> #define MAX 1000 using namespace std; //Function to Add a new inventory item to the data into the array in memory void addItem(string desc[],string idNum[], float prices[], int qty[],int &num) { cout<<"Enter the names:"; cin>>desc[num]; cout<<"Enter the item number:"; cin>>idNum[num]; cout<<"Enter the price of item:"; cin>>prices[num]; cout<<"Enter the...

  • fully comments for my program, thank you will thumb up #include <iostream> #include <fstream> #include <string>...

    fully comments for my program, thank you will thumb up #include <iostream> #include <fstream> #include <string> #include <iomanip> using namespace std; struct book { int ISBN; string Author; string Title; string publisher; int Quantity; double price; }; void choice1(book books[], int& size, int MAX_SIZE) { ifstream inFile; inFile.open("inventory.txt"); if (inFile.fail()) cout <<"file could not open"<<endl; string str;    while(inFile && size < MAX_SIZE) { getline(inFile, str); books[size].ISBN = atoi(str.c_str()); getline(inFile, books[size].Title);    getline(inFile, books[size].Author); getline(inFile, books[size].publisher);          getline(inFile,...

  • c++, I am having trouble getting my program to compile, any help would be appreciated. #include...

    c++, I am having trouble getting my program to compile, any help would be appreciated. #include <iostream> #include <string> #include <string.h> #include <fstream> #include <stdlib.h> using namespace std; struct record { char artist[50]; char title[50]; char year[50]; }; class CD { //private members declared private: string artist; //asks for string string title; // asks for string int yearReleased; //asks for integer //public members declared public: CD(); CD(string,string,int); void setArtist(string); void setTitle(string); void setYearReleased(int); string getArtist() const; string getTitle() const; int...

  • I wrote this code but there’s an issue with it : #include <iostream> #include <vector&...

    I wrote this code but there’s an issue with it : #include <iostream> #include <vector> #include <string> #include <fstream> using namespace std; class Borrower { private: string ID, name; public: Borrower() :ID("0"), name("no name yet") {} void setID(string nID); void setName(string nID); string getID(); string getName(); }; void Borrower::setID(string nID) { ID = nID; } void Borrower::setName(string nname) { name = nname; } string Borrower::getID() { return ID; } string Borrower::getName() { return name; } class Book { private: string...

  • How can I make this compatible with older C++ compilers that DO NOT make use of...

    How can I make this compatible with older C++ compilers that DO NOT make use of stoi and to_string? //Booking system #include <iostream> #include <iomanip> #include <string> using namespace std; string welcome(); void print_seats(string flight[]); void populate_seats(); bool validate_flight(string a); bool validate_seat(string a, int b); bool validate_book(string a); void print_ticket(string passenger[], int i); string flights [5][52]; string passengers [4][250]; int main(){     string seat, flight, book = "y";     int int_flight, p = 0, j = 0;     int seat_number,...

  • #include<iostream> #include<string> #include<iomanip> using namespace std; /* ********* Class Car ************* ********************************* */ class Car {...

    #include<iostream> #include<string> #include<iomanip> using namespace std; /* ********* Class Car ************* ********************************* */ class Car { private: string reportingMark; int carNumber; string kind; bool loaded; string choice; string destination; public: Car() { reportingMark = ""; carNumber = 0; kind = "Others"; loaded = 0; destination = "NONE"; } ~Car() { } void setUpCar(string &reportingMark, int &carNumber, string &kind, bool &loaded, string &destination); }; void input(string &reportingMark, int &carNumber, string &kind, bool &loaded,string choice, string &destination); void output(string &reportingMark, int &carNumber,...

  • 1. in this programe i want add some products to be shown after choosing choise (...

    1. in this programe i want add some products to be shown after choosing choise ( show all products ) before i add any products. let say 10 products have added to the program then when the user choose (show all products ) all the 10 products appear and the user going to choose one and that one must has its own name, price,and quantity after that the quantity will be reduce. 2. allow the user to buy products. ===========================================================...

  • THIS IS FOR C++ PROGRAMMING USING VISUAL STUDIO THE PROGRAM NEEDS TO BE IN C++ PROGRAMMING #inclu...

    THIS IS FOR C++ PROGRAMMING USING VISUAL STUDIO THE PROGRAM NEEDS TO BE IN C++ PROGRAMMING #include "pch.h" #include #include using namespace std; // Function prototype void displayMessage(void); void totalFees(void); double calculateFees(int); double calculateFees(int bags) {    return bags * 30.0; } void displayMessage(void) {    cout << "This program calculates the total amount of checked bag fees." << endl; } void totalFees() {    double bags = 0;    cout << "Enter the amount of checked bags you have." << endl;    cout <<...

  • please Code in c++ Create a new Library class. You will need both a header file...

    please Code in c++ Create a new Library class. You will need both a header file and a source file for this class. The class will contain two data members: an array of Book objects the current number of books in the array Since the book array is moving from the main.cc file, you will also move the constant array size definition (MAX_ARR_SIZE) into the Library header file. Write the following functions for the Library class: a constructor that initializes...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT