C/C++ Help
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Remember me

Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
Unread Dev Articles Community Forums Sponsor:
Old March 23rd, 2014, 12:38 PM
Xinidae Xinidae is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
Join Date: Mar 2014
Posts: 1 Xinidae User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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
int main()
// 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;
char answer;
// 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'));
return 0;
// Add function definitions here.

Reply With Quote

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > General - Help

Developer Shed Advertisers and Affiliates

Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap