Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

using the source codes at the bottom of the page, turn all the different files i

ID: 3906554 • Letter: U

Question

using the source codes at the bottom of the page, turn all the different files into a single file program while using the following instructions.

Serendipity Booksellers Software Development Project— Part 6: A Problem-Solving Exercise

1. Function Name Change

It is now time to make one program from the separate files you have created. Perform the following function name changes:

Change the name of function main in cashier.cpp to cashier.

Change the name of function main in invmenu.cpp to invMenu.

Change the name of function main in bookinfo.cpp to bookInfo.

Change the name of function main in reports.cpp to reports.

Save each file after you have changed the name of its function main.

2. Development Strategy

You must now decide if you are going to develop the project as a multi-file program or simply merge all the functions listed above into the mainmenu.cpp file. (See Appendix K: Multi-Source File Programs)

Multi-File Program

If you decide on the multi-file program approach, follow the directions in your compiler manuals to create a project or “make files” for this program. The files that are part of the project are mainmenu.cpp, cashier.cpp, invmenu.cpp, bookinfo.cpp, and reports.cpp. mainmenu.cpp will be the main file.

Single-File Program

If you decide to merge the functions of the project into one file, simply use the cut and paste feature of your editor to perform the following:

Copy the cashier function in cashier.cpp and paste it into the mainmenu.cpp file.

Copy the invMenu function in invmenu.cpp and paste it into the mainmenu.cpp file.

Copy the bookInfo function in bookinfo.cpp and paste it into the mainmenu.cpp file.

Copy the reports function in reports.cpp and paste it into the mainmenu.cpp file.

3. Header File Creation

Multi-File Program

If you are developing a multi-file program, create the following header files:

cashier.h: This file should contain a function prototype for the cashier function. Place an #include directive in cashier.cpp that includes cashier.h.

invmenu.h: This file should contain a function prototype for the invMenu function. Place an #include directive in invmenu.cpp that includes invmenu.h.

bookinfo.h: This file should contain a function prototype for the bookInfo function. Place an #include directive in bookinfo.cpp that includes bookinfo.h.

reports.h: This file should contain a function prototype for the reports function. Place an #include directive in reports.cpp that includes reports.h.

Single-File Program

If you are developing a single-file program, create a header file named mainmenu.h. It should contain function prototypes for the following functions:

cashier invMenu bookInfo reports

Place an #include directive in mainmenu.cpp that includes mainmenu.h.

4. Switch Modification in main

Modify the switch statement in function main (of mainmenu.cpp) so that instead of displaying the number entered by the user, it calls

function cashier if the user selects 1, function invMenu if the user selects 2, function reports if the user selects 3.

5. Inventory Database Stub Functions

Add stub functions that will later perform operations selected from the Inventory

Database Menu. The functions are

void lookUpBook(). This function should display the message “You selected Look Up Book.”

void addBook(). This function should display the message “You selected Add Book.”

void editBook(). This function should display the message “You selected Edit Book.”

void deleteBook(). This function should display the message “You selected Delete Book.”

Multi-File Program

If you are developing a multi-file program, add the functions above to the invmenu.cpp file. Add function prototypes for each function to invmenu.h.

Single-File Program

If you are developing a single-file program, add the functions above to the mainmenu.cpp file. Add function prototypes for each function to the mainmenu.h file.

6. Switch Modification in invMenu

Modify the switch statement in function invMenu so that instead of

displaying the number entered by the user, it calls

function lookUpBook if the user selects 1, function addBook if the user selects 2, function editBook if the user selects 3, function deleteBook if the user selects 4.

7. Report Stub Functions

Add stub functions that will later perform operations selected from the Reports Menu. The functions are

void repListing(). This function should display the message “You selected Inventory Listing.”

void repWholesale(). This function should display the message “You selected Inventory Wholesale Value.”

void repRetail(). This function should display the message “You selected Inventory Retail Value.”

void repQty(). This function should display the message “You selected Listing By Quantity.”

void repCost(). This function should display the message “You selected Listing By Cost.”

void repAge(). This function should display the message “You selected Listing By Age.”

Multi-File Program

If you are developing a multi-file program, add the functions above to the reports.cpp file. Add function prototypes for each function to reports.h.

Single-File Program

If you are developing a single-file program, add the functions above to the mainmenu.cpp file. Add function prototypes for each function to the mainmenu.h file.

8. Switch Modification in reports

Modify the switch statement in function reports so that instead of

displaying the number entered by the user, it calls

function repListing if the user selects 1, function repWholesale if the user selects 2, function repRetail if the user selects 3, function repQty if the user selects 4, function repCost if the user selects 5, function repAge if the user selects 6.

mainmenu.cpp

#include <iostream>
#include <string>
using namespace std;
int main()
{
            int choice = 0;
            while(choice!=4)
            {
              cout<<" Serendipity Booksellers" <<endl;
              cout<<"         Main Menu"<<endl <<endl;
              cout<<" 1. Cashier Module" <<endl;
              cout<<" 2. Inventory Database Module" <<endl;
              cout<<" 3. Report Module" <<endl;
              cout<<" 4. Exit" << endl;
              cout<<" Enter Your Choice: ";
            
             
              while(1)
              {
                             cin>>choice;
                             if(choice<1 || choice>4)
                             {
                                           cout<<" Please enter a number in the range 1 - 4."<<endl;
                                           cout<<" Enter Your Choice: ";
                             }
                             else
                                           break;
              }
              switch(choice)
              {
                             case 1:
                                           cout<<" You selected item 1";
                                           break;
                             case 2:
                                           cout<<" You selected item 2";
                                           break;
                             case 3:
                                           cout<<" You selected item 3";
                                           break;
                             case 4:
                                           cout<<" You selected item 4";
                                           break;
              }
            }
              return 0;
}

invmenu.cpp

#include <iostream>
#include <string>
using namespace std;
int main()
{
    int choice = 0;
        while(choice!=5)
        {
              cout<<" Serendipity Booksellers" <<endl;
              cout<<"    Inventory Database"<<endl <<endl;
              cout<<" 1. Look Up a Book" <<endl;
              cout<<" 2. Add a Book" <<endl;
              cout<<" 3. Edit a Book's Record" <<endl;
              cout<<" 4. Delete a Book" << endl;
              cout<<" 5. Return to the Main Menu"<<endl <<endl;
              cout<<" Enter Your Choice: ";
            
             
              while(1)
              {
                             cin>>choice;
                             if(choice<1 || choice>5)
                             {
                                           cout<<" Please enter a number in the range 1 - 5."<<endl;
                                           cout<<" Enter Your Choice: ";
                             }
                             else
                                           break;
              }
            
              switch(choice)
              {
                             case 1:
                                           cout<<" You selected item 1";
                                           break;
                             case 2:
                                           cout<<" You selected item 2";
                                           break;
                             case 3:
                                           cout<<" You selected item 3";
                                           break;
                             case 4:
                                           cout<<" You selected item 4";
                                           break;
                             case 5:
                                           cout<<" You selected item 5";
                                           break;
              }
        }
              return 0;
}

reportsmenu.cpp

#include <iostream>
#include <string>
using namespace std;
int main()
{
    int choice = 0;
        while(choice!=7)
        {
              cout<<" Serendipity Booksellers" <<endl;
              cout<<"          Reports"<<endl <<endl;
              cout<<" 1. Inventory Listing" <<endl;
              cout<<" 2. Inventory Wholesale Value" <<endl;
              cout<<" 3. Inventory Retail Value" <<endl;
              cout<<" 4. Listing by Quantity " << endl;
              cout<<" 5. Listing by Cost " << endl;
              cout<<" 6. Listing by Age " <<endl;
              cout<<" 7. Return To Main Menu:"<<endl <<endl;
              cout<<" Enter Your Choice: ";
            
             
              while(1)
              {
                             cin>>choice;
                             if(choice<1 || choice>7)
                             {
                                           cout<<" Please enter a number in the range 1 - 7."<<endl;
                                           cout<<" Enter Your Choice: ";
                             }
                             else
                                           break;
              }
              switch(choice)
              {
                             case 1:
                                           cout<<" You selected item 1";
                                           break;
                             case 2:
                                           cout<<" You selected item 2";
                                           break;
                             case 3:
                                           cout<<" You selected item 3";
                                           break;
                             case 4:
                                           cout<<" You selected item 4";
                                           break;
                             case 5:
                                           cout<<" You selected item 5";
                                           break;
                             case 6:
                                           cout<<" You selected item 6";
                                           break;
                             case 7:
                                           cout<<" You selected item 7";
                                           break;
              }
        }
        return 0;
}

cashier.cpp

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
string date, ISBN, Title;
int numOfBook;
double price, subtotal, tax, total;
int flag=1;
while(flag==1)
{
cout<<" Serendipity 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<<" Subtotal" <<setfill(' ') << setw(6) << "$"<< subtotal << endl;
     cout<<" Tax" << setfill(' ') << setw(6) << "$" << tax <<endl;
     cout<<"Total" << " $" << total <<endl << endl;
     cout<<" ------------------------------------------";
     cout<<" Do you want to continue..??(1 for Yes):";

     cin>>flag;
    cout<<" ------------------------------------------";
}
cout<<"Thank you for shopping at Serendipity!" <<endl;
   
}

bookinfo.cpp

Explanation / Answer

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<<" Serendipity Booksellers" <<endl;
cout<<" Main Menu"<<endl <<endl;
cout<<" 1. Cashier Module" <<endl;
cout<<" 2. Inventory Database Module" <<endl;
cout<<" 3. Report Module" <<endl;
cout<<" 4. Exit" << endl;
cout<<" Enter Your Choice: ";
  
while(1)
{
cin>>choice;
if(choice<1 || choice>4)
{
cout<<" Please enter a number in the range 1 - 4."<<endl;
cout<<" 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<<" You selected item 4";
break;
}
}
return 0;
}

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

cout<<" Serendipity Booksellers" <<endl;
cout<<" 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<<" Serendipity Booksellers" <<endl;
cout<<" Inventory Database"<<endl <<endl;
cout<<" 1. Look Up a Book" <<endl;
cout<<" 2. Add a Book" <<endl;
cout<<" 3. Edit a Book's Record" <<endl;
cout<<" 4. Delete a Book" << endl;
cout<<" 5. Return to the Main Menu"<<endl <<endl;
cout<<" Enter Your Choice: ";
  

while(1)
{
cin>>choice;
if(choice<1 || choice>5)
{
cout<<" Please enter a number in the range 1 - 5."<<endl;
cout<<" 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<<" You selected item 5";
break;
}
}
return 0;
}

int reports()
{
int choice = 0;
while(choice!=7)
{
cout<<" Serendipity Booksellers" <<endl;
cout<<" Reports"<<endl <<endl;
cout<<" 1. Inventory Listing" <<endl;
cout<<" 2. Inventory Wholesale Value" <<endl;
cout<<" 3. Inventory Retail Value" <<endl;
cout<<" 4. Listing by Quantity " << endl;
cout<<" 5. Listing by Cost " << endl;
cout<<" 6. Listing by Age " <<endl;
cout<<" 7. Return To Main Menu:"<<endl <<endl;
cout<<" Enter Your Choice: ";
  
while(1)
{
cin>>choice;
if(choice<1 || choice>7)
{
cout<<" Please enter a number in the range 1 - 7."<<endl;
cout<<" 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<<" 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<<" Serendipity 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<<" Subtotal" <<setfill(' ') << setw(6) << "$"<< subtotal << endl;
cout<<" Tax" << setfill(' ') << setw(6) << "$" << tax <<endl;
cout<<"Total" << " $" << total <<endl << endl;
cout<<" ------------------------------------------";
cout<<" Do you want to continue..??(1 for Yes):";
  
cin>>flag;
cout<<" ------------------------------------------";
}
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