Question: on microsoft visual studio C++ im not sure what it is asking for can you please put the code together for me and run it

on microsoft visual studio C++

im not sure what it is asking for can you please put the code together for me and run it

This week, we learn how to manage complexity by putting together a ready-built application that comprises a number of separate header and source files. Our job here will be to take these individual files and combine them into one standalone application. Although the process is quite a simple one, it will emphasize the advantage of modularity when writing code. It also shows how code can be reused between programmers and/or applications.

STEP 1: Create the Project

Create a new C++ console-based project.

STEP 2: Add Files to Your Project

Unzip the source code and header files found in Doc Sharing (Lab_7_files.zip), and then add these files to your project as needed

here are the files

// Main Program #include #include "cashRegister.h" #include "dispenserType.h"

using namespace std;

void showSelection(); void sellProduct(dispenserType& product, cashRegister& pCounter);

int main() { cashRegister counter; dispenserType candy(100, 50); dispenserType chips(100, 65); dispenserType gum(75, 45); dispenserType cookies(100, 85);

int choice; //variable to hold the selection

showSelection(); cin >> choice;

while (choice != 9) { switch (choice) { case 1: sellProduct(candy, counter); break; case 2: sellProduct(chips, counter); break; case 3: sellProduct(gum, counter); break; case 4: sellProduct(cookies, counter); break; default: cout

showSelection(); cin >> choice; }//end while

return 0; }//end main

void showSelection() { cout

void sellProduct(dispenserType& product, cashRegister& pCounter) { int amount; //variable to hold the amount entered int amount2; //variable to hold the extra amount needed

if (product.getNoOfItems() > 0) //if the dispenser is not //empty { cout > amount;

if (amount > amount2; amount = amount + amount2; }

if (amount >= product.getCost()) { pCounter.acceptAmount(amount); product.makeSale(); cout

cout

//Implementation file dispenserType.cpp //This file contains the definitions of the functions to //implement the operations of the class dispenserType

#include #include "dispenserType.h"

using namespace std;

int dispenserType::getNoOfItems() const { return numberOfItems; }

int dispenserType::getCost() const { return cost; }

void dispenserType::makeSale() { numberOfItems--; }

dispenserType::dispenserType(int setNoOfItems, int setCost) { if (setNoOfItems >= 0) numberOfItems = setNoOfItems; else numberOfItems = 50;

if (setCost >= 0) cost = setCost; else cost = 50; }

//dispenserType Header File

class dispenserType { public: int getNoOfItems() const; //Function to show the number of items in the machine. //Postcondition: The value of numberOfItems is returned.

int getCost() const; //Function to show the cost of the item. //Postcondition: The value of cost is returned.

void makeSale(); //Function to reduce the number of items by 1. //Postcondition: numberOfItems--;

dispenserType(int setNoOfItems = 50, int setCost = 50); //Constructor //Sets the cost and number of items in the dispenser //to the values specified by the user. //Postcondition: numberOfItems = setNoOfItems; // cost = setCost; // If no value is specified for a // parameter, then its default value is // assigned to the corresponding member // variable.

private: int numberOfItems; //variable to store the number of //items in the dispenser int cost; //variable to store the cost of an item };

//Implementation file cashRegisterImp.cpp //This file contains the definitions of the functions to //implement the operations of the class cashRegister

#include #include "cashRegister.h"

using namespace std;

int cashRegister::getCurrentBalance() const { return cashOnHand; }

void cashRegister::acceptAmount(int amountIn) { cashOnHand = cashOnHand + amountIn; }

cashRegister::cashRegister(int cashIn) { if (cashIn >= 0) cashOnHand = cashIn; else cashOnHand = 500; }

//cashRegister Header File

class cashRegister { public: int getCurrentBalance() const; //Function to show the current amount in the cash //register. //Postcondition: The value of cashOnHand is returned.

void acceptAmount(int amountIn); //Function to receive the amount deposited by //the customer and update the amount in the register. //Postcondition: cashOnHand = cashOnHand + amountIn;

cashRegister(int cashIn = 500); //Constructor //Sets the cash in the register to a specific amount. //Postcondition: cashOnHand = cashIn; // If no value is specified when the // object is declared, the default value // assigned to cashOnHand is 500.

private: int cashOnHand; //variable to store the cash //in the register };

STEP 3: Build and Test

Build your project (compile your program).

Eliminate all syntax errors.

Run the program.

STEP 4: Label Title

Capture a screen print of your output [Do a PRINT SCREEN and paste into an MS Word document.]

This is a sample program output:

Zip your project files.

Welcome to Shelly's Candy Shop To select an iten enter 1 for Candy 2 for Chips 3 for Gun 4 for Cookies 9 to exit Please deposit 85 cents 25 Please deposit another 60 cents 60 Collect your item at the botton and enjoy. Welcone to Shelly's Candy Shop To select an iten, enter 1 for Candy 2 for Chips 3 for Gun 4 for Cookies 9 to exit Please deposit 65 cents 65 Collect your item at the bottom and enjoy. Welcone to Shelly's Candy Shop To select an item, enter 1 for Candy 2 for Chips 3 for Gun 4 for Cookies 9 to exit Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!