I am seriously stuck and have been working on this for hours and hours and can't figure out my next step....heres the program assignment.
This vending machine dispenses 1. M&Ms ($.65), 2. Chips ($1.16), 3. Peppermint gum ($.28). Your
program should prompt the user to deposit money (i.e. the user needs to type in the amount deposited at
the prompt), select the product, and provide change. Change should be provided in quarters, dimes, and
pennies (you do not have to use nickel and half-dollar coins.) Include a loop to allow the user repeat a
purchase multiple times. If the amount of money entered is insufficient for the purchase the program should
display a message to the user indicating that. The machine must provide “optimum” change – i.e. the
number of quarters and dimes is maximized. For example if $0.36 is the change due, the machine should
return: 1 quarter, 1 dime, and one penny, NOT zero quarters, 2 dimes, and 16 pennies (or any other
combination.)
Here is an example dialogue. User input is indicated in bold font.
Welcome to online vending machine. It serves:
1. M&M ($.65)
2. Chips ($1.16)
3. Peppermint gum ($.28)
Please enter the amount of money deposited (in dollars): 1.50
Please enter your selection: 2
Please pick up your product.
Your change is: 1 quarter, 0 dimes, 9 pennies
Would you like to make another purchase? (y/n) n
All operations should be done with integers. Do NOT use floating point variables in your program.
Use at least the following functions (besides main()):
1. A function to output the prompts and take in user input;
2. A function find_change that computes the number of coins of each of the specified denominations.
The function should accept the money amount and coin denomination and return the number of coins
for that denomination. For example, if find_change accepts $0.31 as an amount of money and
$0.25 as coin denomination (quarters) it should return 1 (one quarter to be returned.) Hint: use integer
division and remainder operator to implement this function.
You should place your program in several files as follows:
• main.cpp – contains main().
• vendlib.h – contains the global constants and function prototypes.
• vendlib.cpp – contains the function definitions for the functions.
Here's what I got so far:
#include <iostream>
#include "vendlib.h"
using namespace std;
int main ()
{
//Printing out welcome message and what the vending machine serves
cout << "Welcome to online vending machine. It Serves: " << endl;
cout << " 1. M&M's ($.65)" << endl;
cout << " 2. Chips ($1.16)" << endl;
cout << " 3. Peppermint gum ($.28)" << endl;
cout << "Please enter the amount of money deposited (in dollars):" << endl;
// assigning variable and getting the input from the user
double money_deposited;
cin >> money_deposited;
cout << "Please enter your selection:" << endl;
// getting the selection number from the user
double product_selection;
cin >> product_selection;
// instructing the user to pick up the product
cout << "Please pick up your product." << endl;
}
I dont't know what to put in the .h and vendlib.cpp files and I can't figure out a way to get the change to print out how the instructor wants...can anyone help me out please!!!