March 23rd, 2014, 11:38 AM
Join Date: Mar 2014
Time spent in forums: 52 m 25 sec
Reputation Power: 0
General - Help
I have 4 hours left to write a code to simulate a person putting money into a vending machine for an energy drink. This is the code that was supplied and i would put a pic of what it's supposed to look like but it won't let me add a pic so pm me for one if you want it
/ William Mink
// Mid term exam
// This program allows the user to calculate the money spent so far, and the total cost of
// the Monster Energy Drink
using namespace std;
const int MONSTER_PRICE = 145;
// We will use cents for all monetary values. This will let us
// work with integer, rather than floating-point, variables.
// Function declarations must be added here.
int accept_money(); // Here is one to get you started
// Declare variables for the amount of money that the user enters,
// along with the change that is to be returned to them.
int money_entered, change;
// Make sure that monetary values we output are formatted with
// two digits after the decimal point.
// Collect money from the user
money_entered = accept_money();
// Function prompts user to insert coins until enough has been paid to buy
// a Monster Energy Drink. The total amount inserted, in cents, is returned.
// Figure out how much change to return
change = compute_change(money_entered);
// Function returns the amount of change to be returned to the user.
// Dispense the drink
cout << "\n\nEnjoy your Monster drink. Your change is $"
<< change/100.0 << endl << endl;
cout << "Would you like to purchase another? Enter Y for yes, any other key to Quit" << endl;
cin >> answer;
} while ((answer == 'Y') || (answer == 'y'));
// Add function definitions here.