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

In my class, I was asked to create two versions of a program that creates a cash

ID: 3567214 • Letter: I

Question

In my class, I was asked to create two versions of a program that creates a cash register system for a bookstore: one being a single file program, and the other using multiple files to create the program.

I made the single file one here and it works fine here:

// Serendipity Booksellers Main Menu Screen
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

void printHeader(int hw, string lastModified);

//Main Function Prototypes
void cashier();
void invMenu();

//Prototypes for invMenu function
void lookUpBook();
void addBook();
void editBook();
void deleteBook();

//Prototypes for reports function
void repListing();
void repWholesale();
void repRetail();
void repQty();
void repCost();
void repAge();

//for later: void bookInfo();

void reports();

//housekeeping function prototype
void housekeeping();

int main()
{
printHeader(11, "11/02/2014");
cout << endl;

   //Variables Declaration
string choiceValue;
     
enum Menu
     
{
CASHIER_MOD = 1, INV_DATABASE_MOD, REPORT_MOD, EXIT
  
};
     
int choice = 0;

  

//Output Section (Program Start)
   do
   
{
  
cout << right << setw(51) << "Serendipity Booksellers" << endl;
  
cout << setw(44) << "Main Menu" << endl << endl;
  
cout << "1. Cashier Module" << endl;
  
cout << "2. Inventory Database Module" << endl;
  
cout << "3. Report Module" << endl;
     
cout << "4. Exit" << endl << endl;

  //Input Section

do

{

cout << "Please enter your choice (1-4): ";

cin >> choice;

cout << endl;

} while ((choice < 1) || (choice > 4));

  

switch(choice)

{

case CASHIER_MOD:

cashier();

break;

case INV_DATABASE_MOD:

invMenu();

break;

case REPORT_MOD:

reports();

break;

case EXIT:

cout << "You have chosen to exit the program." << endl;

break;

}

  

//Output Section (Program End)

cout << choiceValue << endl << endl;

  

}while (choice <= 3);

housekeeping();

  return 0;

}

/************************************************************

* DESCRIPTION : prints author box (name, hw #, etc.) to console

* PRECONDITIONS : hw and lastModified are valid values

* POSTCONDITIONS : author box printed to console

************************************************************/

void printHeader(int hw, string lastModified)

{

//OUTPUT

cout << left;

cout << setw(15) << "Name:" << "Cory" << endl;

cout << setw(15) << "HW #:" << hw << endl;

cout << setw(15) << "Section: " << "CS150 MW 3:30-5:20pm" << endl;

cout << setw(15) << "Last Modified:" << lastModified << endl;

}

/************************************************************

* DESCRIPTION : Gathers various information from user in

order to to create a sales receipt

* PRECONDITIONS : <none>

* POSTCONDITIONS : Sales Receipt is Generated

************************************************************/

void cashier()

{

//Constants

const double TAX_RATE = .06;

  

//Variables

string date, ISBN, bookTitle;

int qty;

double unitPrice, subTotal, total, salesTax;

char anotherTransaction;

  

  

//Output Section (Program start)

cout << "Serendipity Booksellers" << endl;

cout << "Cashier Module" << endl << endl;

  

do

{

//Input Section

cout << "-----------------------------------------------------------------------------" << endl;

cout << "Please enter the following information:" << endl << endl;

cout << "Date (MM/DD/YY): ";

cin >> date;

cout << "Quantity: ";

cin >> qty;

cout << "ISBN: ";

cin >> ISBN;

cin.ignore(1000, ' ');

cout << "Book Title: ";

getline(cin, bookTitle);

cout << "Price per unit: $ ";

cin >> unitPrice;

cout << endl;

  

//Output Section (Program Cont.)

cout << setw(25) << left;

cout << "Serendipity Booksellers" << endl;

cout << endl;

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

  

cout << setw(8);

cout << "Qty";

cout << setw(15);

cout << "ISBN";

cout << setw(34);

cout << "Title";

cout << setw(12);

cout << "Price";

cout << right;

cout << setw(8);

cout << "Total" << endl;

cout << left << setw(12);

cout <<"_____________";

cout << right << setw(35);

cout << "_________________________________________________________________" << endl;

  

//Processing Section

subTotal = unitPrice * qty;

salesTax = subTotal * TAX_RATE;

total = subTotal + salesTax;

  

//Output Section (Program End)

cout << left << setw(8) << qty;

cout << setw(15) << ISBN;

cout << setw(32) << bookTitle;

cout << "$ " << setw(14) << fixed << setprecision(2) << unitPrice;

cout << "$" << right << setw(6) << subTotal;

  

cout << endl << endl << endl;

  

cout << right;

cout << setw(31) << "Subtotal";

cout << setw(41) << "$"<< fixed << setprecision(2) << setw(6) << subTotal << endl;

  

cout << setw(26) << "Tax";

cout << setw(46) << "$" << fixed << setw(6) << salesTax << endl;

  

cout << setw(28) << "Total";

cout << setw(44) << "$" << fixed << setw(6)<< total << endl;

  

  

cout << endl;

  

cout << "Would you like to process another transaction? (Y/N): ";

cin >> anotherTransaction;

cout << endl;

}while (anotherTransaction == 'Y' || anotherTransaction == 'y');

  

cout << "Thank You For Shopping Serendipity!" << endl << endl;

  

  

  

//Housekeeping

cin.ignore(1000, ' ');

cout.unsetf(ios::fixed);

cout << setprecision(6);

  

}

/************************************************************

* DESCRIPTION : Runs a switch statement depending on user's

choice

* PRECONDITIONS : none

* POSTCONDITIONS : Switch statement calls function depending

on user's choice

************************************************************/

void invMenu()

{

//Variables Declaration

string choiceValue;

enum Menu

{

LOOKUP_BOOK = 1, ADD_BOOK, EDIT_BOOK, DELETE_BOOK, RETURN

};

int choice = 0;

  

//Input Section

do

{

cout << setw(51) << "Serendipity Booksellers" << endl;

cout << setw(49) << "Inventory Database" << endl << endl;

cout << "1. Look-Up a Book" << endl;

cout << "2. Add a Book" << endl;

cout << "3. Edit a Book's Records" << endl;

cout << "4. Delete a Book" << endl;

cout << "5. Return to the Main Menu" << endl << endl;

  

//Processing

do

{

cout << "Please enter your choice: ";

cin >> choice;

cout << endl;

}while ((choice < 1) || (choice > 5));

  

  

//Processing

switch (choice)

{

case LOOKUP_BOOK:

lookUpBook();

break;

case ADD_BOOK:

addBook();

break;

case EDIT_BOOK:

editBook();

break;

case DELETE_BOOK:

deleteBook();

break;

case RETURN:

main();

break;

}

  

//Output Section (Program End)

cout << choiceValue << endl << endl;

  

}while (choice <= 4);

  

}

void bookInfo()

{

cout << setw(45) << "Serendipity Booksellers" << endl;

cout << setw(42) << "Book Information" << endl;

  

cout << endl;

  

cout << left << setw(20);

cout << "ISBN: " << endl;

cout << "Title: " << endl;

cout << "Author: " << endl;

cout << "Publisher: " << endl;

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

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

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

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

  

//House Cleaning

cout << right;

}

/************************************************************

* DESCRIPTION : Reads int from user and runs value through

enums in a switch statement depending on user's

choice

* PRECONDITIONS : none

* POSTCONDITIONS : Switch statement calls function depending

on user's choice

************************************************************/

void reports()

{

//Variables Declaration

string choiceValue;

enum Menu

{

INV_LISTING = 1, INV_WHOLESALE_VAL, INV_RETAIL_VAL, LISTING_BY_QTY, LISTING_BY_COST, LISTING_BY_AGE, RETURN

};

int choice = 0;

  

//Input Section

do

{

  

cout << setw (51) << "Serendipity Booksellers" << endl;

cout << setw(43) << "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 the Main Menu" << endl << endl;

  

//Processing

do

{

cout << "Enter your choice: ";

cin >> choice;

cout << endl;

}while ((choice < 1) || ( choice > 7));

  

cout << endl;

  

//Processing

switch (choice)

{

case INV_LISTING:

repListing();

break;

case INV_WHOLESALE_VAL:

repWholesale();

break;

case INV_RETAIL_VAL:

repRetail();

break;

case LISTING_BY_QTY:

repQty();

break;

case LISTING_BY_COST:

repCost();

break;

case LISTING_BY_AGE:

repAge();

break;

case RETURN:

main();

break;

}

  

//Output Section (Program End)

cout << choiceValue << endl << endl;

  

}while (choice <= 6);

  

}

//invMenu function Definitions

void lookUpBook()

{

cout << "STUB: You have chosen to look-up a book.";

}

void addBook()

{

cout << "STUB: You have chosen to add a book.";

}

void editBook()

{

cout << "STUB: You have chosen to edit a book's records.";

}

void deleteBook()

{

cout << "STUB: You have chosen delete a book.";

}

//reports function Definitions

void repListing()

{

cout << "STUB: You have chosen to view Inventory Listings.";

}

void repWholesale()

{

cout << "STUB: You have chosen to view Inventory Wholesale Values.";

}

void repRetail()

{

cout << "STUB: You have chosen to view Inventory Retail Values.";

}

void repQty()

{

cout << "STUB: You have chosen to view Listings by Quantity.";

}

void repCost()

{

cout << "STUB: You have chosen to view Listings by Cost.";

}

void repAge()

{

cout << "STUB: You have chosen to view Listings by Age.";

}

/************************************************************

* DESCRIPTION : does housekeeping for end of program

* PRECONDITIONS : <none>

* POSTCONDITIONS : resets output manipulators to defaults

************************************************************/

void housekeeping()

{

cin.ignore(1000, ' ');

cout << right;

cout.unsetf(ios::fixed);

cout << setprecision(6);

}



but I

Explanation / Answer

Program cod:

// CashierImplementationMultiplefile.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"

// Serendipity Booksellers Main Menu Screen

#include <iostream>

#include <iomanip>

#include <string>

#include "Cashier.h"

#include "InvMenu.h"

#include "bookInfo.h"

#include "reports.h"

using namespace std;

//housekeeping function prototype

void housekeeping();

int main()

{

     cout << endl;

     //Variables Declaration

     string choiceValue;

     enum Menu

     {

          CASHIER_MOD = 1, INV_DATABASE_MOD, REPORT_MOD, EXIT

     };

     int choice = 0;

     //Output Section (Program Start)

     do

     {

          cout << right << setw(51) << "Serendipity Booksellers" << endl;

          cout << setw(44) << "Main Menu" << endl << endl;

          cout << "1. Cashier Module" << endl;

          cout << "2. Inventory Database Module" << endl;

          cout << "3. Report Module" << endl;

          cout << "4. Exit" << endl << endl;

          //Input Section

          do

          {

              cout << "Please enter your choice (1-4): ";

              cin >> choice;

              cout << endl;

          }   while ((choice < 1) || (choice > 4));

          switch(choice)

          {

          case CASHIER_MOD:

              cashier();

              break;

          case INV_DATABASE_MOD:

              invMenu();

              break;

          case REPORT_MOD:

              reports1();

              break;

          case EXIT:

              cout << "You have chosen to exit the program." << endl;

              break;

          }

          //Output Section (Program End)

          cout << choiceValue << endl << endl;

     }while (choice <= 3);

     return 0;

}

//Cashier.h File:

#ifndef Cashier

#define Cashier

//Fuction Prototype

void cashier();

#endif

//Cashier.cpp:

//Serendipity Booksellers Cashier Screen

#include "stdafx.h"

#include <iostream>

#include <iomanip>

#include <string>

#include "Cashier.h"

using namespace std;

void cashier()

{

    //Constants

    const double TAX_RATE = .06;

  

//Variables

    string date, ISBN, bookTitle;

    int qty;

    double unitPrice, subTotal, total, salesTax;

    char anotherTransaction;

    //Output Section (Program start)

    cout << "Serendipity Booksellers" << endl;

    cout << "Cashier Module" << endl << endl;

    do

    {

        //Input Section

        cout << "-----------------------------------------------------------------------------" << endl;

        cout << "Please enter the following information:" << endl << endl;

        cout << "Date (MM/DD/YY): ";

        cin >> date;

        cout << "Quantity: ";

        cin >> qty;

        cout << "ISBN: ";

        cin >> ISBN;

        cin.ignore(1000, ' ');

        cout << "Book Title: ";

        getline(cin, bookTitle);

        cout << "Price per unit: $ ";

        cin >> unitPrice;

        cout << endl;

      

        //Output Section (Program Cont.)

        cout << setw(25) << left;

        cout << "Serendipity Booksellers" << endl;

        cout << endl;

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

        cout << setw(8);

        cout << "Qty";

        cout << setw(15);

        cout << "ISBN";

        cout << setw(34);

        cout << "Title";

        cout << setw(12);

        cout << "Price";

        cout << right;

        cout << setw(8);

        cout << "Total" << endl;

        cout << left << setw(12);

        cout <<"_____________";

        cout << right << setw(35);

        cout << "_________________________________________________________________" << endl;      

        //Processing Section

        subTotal = unitPrice * qty;

        salesTax = subTotal * TAX_RATE;

        total = subTotal + salesTax;

        //Output Section (Program End)

        cout << left << setw(8) << qty;

        cout << setw(15) << ISBN;

        cout << setw(32) << bookTitle;

        cout << "$ " << setw(14) << fixed << setprecision(2) << unitPrice;

        cout << "$" << right << setw(6) << subTotal;

      

        cout << endl << endl << endl;

      

        cout << right;

        cout << setw(31) << "Subtotal";

        cout << setw(41) << "$"<< fixed << setprecision(2) << setw(6) << subTotal << endl;     

        cout << setw(26) << "Tax";

        cout << setw(46) << "$" << fixed << setw(6) << salesTax << endl;

      

        cout << setw(28) << "Total";

        cout << setw(44) << "$" << fixed << setw(6)<< total << endl;

      

      

        cout << endl;

      

        cout << "Would you like to process another transaction? (Y/N): ";

        cin >> anotherTransaction;

        cout << endl;

    }while (anotherTransaction == 'Y' || anotherTransaction == 'y');

  

    cout << "Thank You For Shopping Serendipity!" << endl << endl;

    //Housekeeping

    cin.ignore(1000, ' ');

    cout.unsetf(ios::fixed);

    cout << setprecision(6);

}

//InvMenu.h File:

#ifndef InvMenu

#define InvMenu

//Function Prototypes

void invMenu();

void lookUpBook();

void addBook();

void editBook();

void deleteBook();

#endif

//InvMenu.cpp:

// This is the Inventory Database Menu Module for Serendipity Booksellers' POS Program

#include "stdafx.h"

#include <iostream>

#include <iomanip>

#include <string>

#include "InvMenu.h"

using namespace std;

void invMenu()

{

    //Variables Declaration

    string choiceValue;

    enum Menu

    {

        LOOKUP_BOOK = 1, ADD_BOOK, EDIT_BOOK, DELETE_BOOK, RETURN

    };

    int choice = 0;

  

    //Input Section

    do

    {

        cout << setw(22) << " " << "Serendipity Booksellers" << endl;

        cout << setw(24) << " " << "Inventory Database" << endl << endl;

        cout << "1. Look-Up a Book" << endl;

        cout << "2. Add a Book" << endl;

        cout << "3. Edit a Book's Records" << endl;

        cout << "4. Delete a Book" << endl;

        cout << "5. Return to the Main Menu" << endl << endl;

        //Processing

        do

        {

            cout << "Please enter your choice: ";

            cin >> choice;

            cout << endl;

        }   while ((choice < 1) || (choice > 5));

        //Processing

        switch (choice)

        {

            case LOOKUP_BOOK:

                lookUpBook();

                break;

            case ADD_BOOK:

                addBook();

                break;

            case EDIT_BOOK:

                editBook();

                break;

            case DELETE_BOOK:

                deleteBook();

                break;

            case RETURN:

                choiceValue = "You have chosen to return to the Main Menu.";

                break;

        }

      

        //Output Section (Program End)

        cout << choiceValue << endl << endl;

      

    }while (choice <= 5);

  

}

void lookUpBook()

{

    cout << "You selected Look Up Book" << endl;

}

void addBook()

{

    cout << "You selected Add Book" << endl;

}

void editBook()

{

    cout << "You selected Edit Book" << endl;

}

void deleteBook()

{

    cout << "You selected Delete Book." << endl;

}

//bookInfo.h File:

#ifndef bookInfo

#define bookInfo

//Function Prototype

void bookInfo1();

#endif

//bookInfo.cpp:

// This is the Program for Serendipity Booksellers Book Info Screen

#include "stdafx.h"

#include <iostream>

#include <iomanip>

#include "bookInfo.h"

using namespace std;

void bookInfo1()

{

    cout << setw(45);

    cout << "Serendipity Booksellers" << endl;

    cout << setw(42);

    cout << "Book Information" << endl;

  

    cout << endl;

  

    cout << left << setw(20);

    cout << "ISBN: " << endl;

    cout << "Title: " << endl;

    cout << "Author: " << endl;

    cout << "Publisher: " << endl;

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

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

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

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

  

    //House Cleaning

    cout << right;

}

//reports.h File:

#ifndef reports

#define reports

//Function Prototypes

void reports1();

void repListing();

void repWholesale();

void repRetail();

void repQty();

void repCost();

void repAge();

#endif

//reports.cpp:

// This Program is the Reports Screen for Serendipity Booksellers

#include "stdafx.h"

#include <iostream>

#include <iomanip>

#include <string>

#include "reports.h"

using namespace std;

void reports1()

{

    //Variables Declaration

    string choiceValue;

    enum Menu

    {

        INV_LISTING = 1, INV_WHOLESALE_VAL, INV_RETAIL_VAL, LISTING_BY_QTY, LISTING_BY_COST, LISTING_BY_AGE,RETURN

    };

    int choice = 0;

  

    //Input Section

    do

    {

      

        cout << setw (22) << " " << "Serendipity Booksellers" << endl;

        cout << setw(30) << " " << "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 the Main Menu" << endl << endl;

      

        //Processing

        do

        {

          cout << "Enter your choice: ";

            cin >> choice;

            cout << endl;

        }   while ((choice < 1) || ( choice > 7));

      

        cout << endl;

      

        //Processing

        switch (choice)

        {

            case INV_LISTING:

                repListing();

                break;

            case INV_WHOLESALE_VAL:

                repWholesale();

                break;

            case INV_RETAIL_VAL:

                repRetail();

                break;

            case LISTING_BY_QTY:

                repQty();

                break;

            case LISTING_BY_COST:

                repCost();

                break;

            case LISTING_BY_AGE:

                repAge();

                break;

            case RETURN:

                choiceValue = "You have chosen to return to the Main Menu.";

                break;

        }     

        //Output Section (Program End)

        cout << choiceValue << endl << endl;     

    }while (choice <=7);

}

void repListing()

{

    cout << "You selected Inventory Listing." << endl;

}

void repWholesale()

{

     cout << "You selected Inventory Wholesale Value." << endl;

}

void repRetail()

{

    cout << "You selected Inventory Retail Value." << endl;

}

void repQty()

{

    cout << "You selected Listing By Quantity" << endl;

}

void repCost()

{

     cout << "You selected Listing By Cost" << endl;

}

void repAge()

{

    cout << "You selected Listing ny Age" << endl;

}

Note: Changed code is in bold letters.

Note: while creating header files, the methods or classes need to be defined inside the header definition. Such as,

#ifndef header_name

#define header_name

      //declare the class or function prototype.

#endif

Avoid including .cpp files where ever they are being implemented. Just declare the required fuctions or classes in the header files, then define the functions or class methods in respective .cpp file. Import the header files in the implementation(main) by calling the functions.

If required maintain the multiple infomation, utilize the arrays or vectors.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote