In the wake of COVID-19, a new vending machine is going to be installed at SSU that provides items that can potentially mitigate the spreading of this virus among the SSU community. The machine sells the following items at a subsidized rate: hand sanitizer, mask, tissues, and wet wipes. You are tasked with writing a program for this machine so that it can put into operation.
This project should do the following:
This vending machine has two main components: a built-in cash register (cashRegister) and several dispensers (dispenserType) to hold and release the products.
For CheckPoint A, you will create a class dispenserType to build the dispenser:
(1) Create three files to submit. Templates for these files can be downloaded from below. These files are:
Build the dispenserType class with the following specifications. For each unique product offered in a vending machine, there will be a corresponding dispenserType.
Default constructor
Public class functions (mutators and accessors) - you may choose to make some of the functions below as const
-setName() - Function to set the object's name (a data member).
-getName() - Function to show the name of selected item. The name of the given item is returned.
-setNoOfItems() - Function to set the object's numberOfItem (a data member).
-getNoOfItems() - Function to show the number of items in the machine. The value of numberOfItems is returned.
-setCost() - Function to set the object's cost (a data member).
-getCost() - Function to show the cost of selected item. The cost of the given item is returned.
Private data members
-string name - Initialized in default constructor to "none"
-int numberOfItem - Initialized in default constructor to 0
-int cost - Initialized in default constructor to 0
No changes are needed to be made to main.cpp for this CheckPoint. When main.cpp is executed, the user is presented a menu where they can make a selection for one of the preexisting products. The purchase will continue until the user enters 9 to exit.
The following output is expected in the context of CLion.
(1) When the prompt is
*** Welcome to SSU Vending Machine *** To select an item, enter 1 for Sanitizer 2 for Mask 3 for Tissues 4 for Wipes 9 to exit
and user enters 1, then the output is
You chose Sanitizer. Please keep 60 cents ready. *** Welcome to SSU Vending Machine *** To select an item, enter 1 for Sanitizer 2 for Mask 3 for Tissues 4 for Wipes 9 to exit (continue prompting user...)
When the prompt is
*** Welcome to SSU Vending Machine *** To select an item, enter 1 for Sanitizer 2 for Mask 3 for Tissues 4 for Wipes 9 to exit
and user enters 9, then the program terminates.
-
=====
main.cpp
=====
#include
#include "dispenserType.h"
using namespace std;
void showSelection();
void sellProduct(dispenserType&);
int main() {
//cashRegister counter;
dispenserType sanitizer;
sanitizer.setCost(60);
sanitizer.setName("Sanitizer");
sanitizer.setNoOfItems(100);
dispenserType mask;
mask.setCost(85);
mask.setName("Mask");
mask.setNoOfItems(100);
dispenserType tissues;
tissues.setCost(25);
tissues.setName("Tissues");
tissues.setNoOfItems(100);
dispenserType wipes;
wipes.setCost(100);
wipes.setName("Wipes");
wipes.setNoOfItems(100);
int choice;
showSelection();
cin >> choice;
while (choice != 9) {
switch (choice) {
case 1:
sellProduct(sanitizer);
break;
case 2:
sellProduct(mask);
break;
case 3:
sellProduct(tissues);
break;
case 4:
sellProduct(wipes);
break;
default:
cout << "Invalid selection" << endl;
} // end switch
showSelection();
cin >> choice;
} // end while;
return 0;
} // end main
void showSelection() {
cout << "*** Welcome to SSU Vending Machine ***" <<
endl; cout << "To select an item, enter " <<
endl;
cout << "1 for Sanitizer" << endl;
cout << "2 for Mask" << endl;
cout << "3 for Tissues" << endl;
cout << "4 for Wipes" << endl;
cout << "9 to exit" << endl;
}//end showSelection
void sellProduct(dispenserType& product){
cout << "You chose " << product.getName() << ".
Please keep " << product.getCost() << " cents ready."
<< endl;
cout << endl;
} //end sellProduct
=====
-
=====
dispenserType.cpp
=====
#include "dispenserType.h"
=====
-
=====
dispenserType.h
=====
#include
using namespace std;
class dispenserType{
public:
private:
};
=====
SNAPSHOT OF CODE :


CODE :
"dispenserType.h"
#include <iostream> // Including Header Files using namespace std; // Class Declaration class dispenserType { // Private Data Members private: string name; int numberOfItem; int cost; // Public Data Members public: // Declaring Constructor dispenserType(); // Declaring Functions void setName(string name); string getName(); void setNoOfItems(int items); int getNoOfItems(); void setCost(int cost); int getCost(); };
"dispenserType.cpp"
#include "dispenserType.h" // Including Necessary Header Files #include <iostream> using namespace std; // Defining Class Constructor dispenserType::dispenserType() { name = "None"; numberOfItem = 0; cost = 0; } // Defining Class Methods void dispenserType::setName(string name) { this->name = name; } string dispenserType::getName() { return this->name; } void dispenserType::setNoOfItems(int items) { this->numberOfItem = items; } int dispenserType::getNoOfItems() { return this->numberOfItem; } void dispenserType::setCost(int cost) { this->cost = cost; } int dispenserType::getCost() { return this->cost; }
OUTPUT :


// Feel Free To Ask Any Question !!!
// Keep Then Happy Chegging !!!
// Thank You !!!
In the wake of COVID-19, a new vending machine is going to be installed at SSU...
CODES: main.cpp #include <iostream> #include <string> #include "ShoppingCart.h" using namespace std; char PrintMenu() { char answer; cout << "MENU" << endl; cout << "a - Add item to cart" << endl; cout << "d - Remove item from cart" << endl; cout << "c - Change item quantity" << endl; cout << "i - Output items' descriptions" << endl; cout << "o - Output shopping cart" << endl; cout << "q - Quit" << endl << endl; while (true) {...
Exercise 2: There can be several constructors as long as they differ in number of parameters or data type. Alter the program so that the user can enter just the radius, the radius and the center, or nothing at the time the object is defined. Whatever the user does NOT include (radius or center) must be initialized somewhere. There is no setRadius function and there will no longer be a setCenter function. You can continue to assume that the default...
Redo Programming Exercise 7 of Chapter 7 so that your program handles exceptions such as division by zero and invalid input. Your program should print Denominator must be nonzero and reprompt for a valid denominator when 0 is entered for a denominator. Please specify what should go in the divisionByZero.h file and the changes made to main.cpp Please provide output. Thank you in advance! main.cpp so far #include <iostream> using namespace std; void addFractions(int num1, int num2, int den1, int...
C++ Design a class bankAccount that defines a bank account as an ADT and implements the basic properties of a bank account. The program will be an interactive, menu-driven program. a. Each object of the class bankAccount will hold the following information about an account: account holder’s name account number balance interest rate The data members MUST be private. Create an array of the bankAccount class that can hold up to 20 class objects. b. Include the member functions to...
C++
#include <iostream>
using namespace std;
bool checkinventoryid(int id)
{
return id > 0;
}
bool checkinventoryprice(float price)
{
return price > 0;
}
void endProgram()
{
system("pause");
exit(0);
}
void errorID(string str)
{
cout << "Invalid Id!!! " << str
<< " should be greater than 0" << endl;
}
void errorPrice(string str)
{
cout << "Invalid Price!!!" << str
<< " should be greater than 0" << endl;
}
int inputId()
{...
I need help with this assignment, can someone HELP ? This is the assignment: Online shopping cart (continued) (C++) This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). (1) Extend the ItemToPurchase class per the following specifications: Parameterized constructor to assign item name, item description, item price, and item quantity (default values of 0). (1 pt) Public member functions SetDescription() mutator & GetDescription() accessor (2 pts) PrintItemCost() - Outputs the item name followed by...
IP requirements: Load an exam Take an exam Show exam results Quit Choice 1: No functionality change. Load the exam based upon the user's prompt for an exam file. Choice 2: The program should display a single question at a time and prompt the user for an answer. Based upon the answer, it should track the score based upon a successful answer. Once a user answers the question, it should also display the correct answer with an appropriate message (e.g.,...
Program is in C++, program is called airplane reservation. It is suppose to display a screen of seating chart in the format 1 A B C D E F through 10. I had a hard time giving the seats a letter value. It displays a correct screen but when I reserve a new seat the string seats[][] doesn't update to having a X for that seat. Also there is a file for the struct called systemUser.txt it has 4 users...
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...
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...