Question: C++Question Objectives After this lab assignment, students should be able to . Declare and define structs Implement designs using structs Instructions In this lab, we

C++Question

C++Question Objectives After this lab assignment, students should be able to .

Declare and define structs Implement designs using structs Instructions In this lab,

we will create an abstraction of a vending machine in C++, using

Objectives After this lab assignment, students should be able to . Declare and define structs Implement designs using structs Instructions In this lab, we will create an abstraction of a vending machine in C++, using structs to describe each item in the machine, and a vector to maintain a list of all the items in the machine Use the following struct declaration for vending machine items struct item string name; // name of the item int code// numerical code entered to select the item float price: 1/ price per unit of the item int stock; // number of items available in the machine Use the following vector declaration for the vending machine int main) [ vector vendingMachine; Complete the three following function headers shown below: float totalValue (vectorKitem> vendingMachine) // return the total value of all items in the vending machine void stock (string name , int count, vectoritem> &vendingMachine) // add "count" items to the vending machine with the given "name" // if the item to be added was not already in the machine, prompt the // user for its code and price (in dollars) // if the code is already being used by the machine, prompt the user for // a different code void purchase (float balance, int code, vector &vendingMachine) // make a purchase from the vending machine // "balance" is the amount of money (in dollars) inserted // "code" is the item to purchase // f "code" is not mapped to an iten, display error message // if the item is more expensive than "balance", display error message // if purchase is successful, display change to be returned in dollars // and update the stock of that item

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!