Click here to Skip to main content
15,903,744 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Why the controls do not show? Pin
yu-jian9-Dec-10 0:52
yu-jian9-Dec-10 0:52 
QuestionHow can identify click on hashbutton or item label in Tree Ctrel? Pin
Le@rner3-Dec-10 23:00
Le@rner3-Dec-10 23:00 
AnswerRe: How can identify click on hashbutton or item label in Tree Ctrel? Pin
User 74293383-Dec-10 23:38
professionalUser 74293383-Dec-10 23:38 
Questionhow to input into array from keyboard Pin
atoivan3-Dec-10 16:20
atoivan3-Dec-10 16:20 
AnswerRe: how to input into array from keyboard Pin
Dr.Walt Fair, PE3-Dec-10 16:36
professionalDr.Walt Fair, PE3-Dec-10 16:36 
AnswerRe: how to input into array from keyboard Pin
Luc Pattyn3-Dec-10 17:20
sitebuilderLuc Pattyn3-Dec-10 17:20 
AnswerRe: how to input into array from keyboard [modified] Pin
Alain Rist3-Dec-10 23:55
Alain Rist3-Dec-10 23:55 
QuestionC++ Drink Machine Simulator Can anyone tell what I am doing wrong with this? Pin
Cachel3-Dec-10 15:00
Cachel3-Dec-10 15:00 
/* Program: Drink Machine
Programmer: Cachel Caldiero
Date: November 16, 2010
Purpose: Simulate a drink machine
*/

#include <iostream>
#include <string>

using namespace std;

// Function Prototypes
void banner();
void menu();
int getMoney();
bool enough(double);
void getDrink();
void dispenseChange(double);

// Main function

int main ()
{
double money = 0.0;

//display banner
banner();
menu();

//While not enough money
while (!enough(money))
{
//Add money based upon option selected
switch (getMoney())
{
case 1: cout << "You have entered $1.00" << endl;
break;
case 2: cout << "You have entered 25 cents" << endl;
break;
case 3: cout << "You have entered 10 cents" << endl;
break;
case 4: cout << "You have entered 5 cents" << endl;
break;
}

//Tell user how much money has been deposited already
cout << endl << "Current amount deposited is " << money << endl;
}

//determine drink selection
getDrink();

//dispense change
if (money > 1.00)
dispenseChange(money);

return 0;
}

// Function Definitions
void banner()
{
cout << "MMM DDD" << endl
<< "OOO EEE" << endl
<< "UUU WWW" << endl
<< "NNN " << endl
<< "TTT " << endl
<< "AAA " << endl
<< "III " << endl
<< "NNN " << endl;
}

void menu()
{
cout << "Pick your drink" << endl
<< "1. Pepsi" << endl
<< "2. Diet Pepsi" << endl
<< "3. Mountain Dew" << endl
<< "4. Diet Mountain Dew" << endl
<< "5. Bottled Water" << endl;
}

int getMoney()
{
int opt;

cout << "Please deposit $0.25." << endl;

cout << "1.Dollar" << endl
<< "2.Quarter" << endl
<< "3.Dime" << endl
<< "4.Nickel" << endl;

cin >> opt;

return opt;
}

bool enough(double m)
{
bool opt(double);
//is there enough money?
if (opt >= enough)
cout << "Enough money inserted" << endl;
else
cout << "Need more money" << endl;
}

void getDrink()
{
string drinkSelection = "";
int option;

//display selection menu
cout << "Pick your drink" << endl;

cout << "1.Pepsi" << endl
<< "2.Diet Pepsi" << endl
<< "3.Mountain Dew" << endl
<< "4.Diet Mountain Dew" << endl
<< "5.Bottled Water" << endl;

//read input selection for drink
cin >> option;


//determine what drink is selected
getDrink();

//output here is your drink.. message
cout << "Here is your drink" << endl;
}

void dispenseChange(double m)
{
int getMoney();

//determine the change in coins.. for example 2 dimes, 1 nickel.

if (getMoney == 1)
cout << "Your change is $0.75 or 3 quarters.";
if (getMoney == 2)
cout << "Your change is $0.50 or 2 quarters.";
else if (getMoney == 3)
cout << "Your change is $0.25 or 1 quarter.";

}

AnswerRe: C++ Drink Machine Simulator Can anyone tell what I am doing wrong with this? Pin
Dr.Walt Fair, PE3-Dec-10 16:26
professionalDr.Walt Fair, PE3-Dec-10 16:26 
GeneralRe: C++ Drink Machine Simulator Can anyone tell what I am doing wrong with this? Pin
Cachel3-Dec-10 19:34
Cachel3-Dec-10 19:34 
GeneralRe: C++ Drink Machine Simulator Can anyone tell what I am doing wrong with this? [modified] Pin
User 74293383-Dec-10 22:24
professionalUser 74293383-Dec-10 22:24 
GeneralRe: C++ Drink Machine Simulator Can anyone tell what I am doing wrong with this? Pin
Maximilien4-Dec-10 7:22
Maximilien4-Dec-10 7:22 
QuestionRead data using assembly Pin
MKC0023-Dec-10 2:39
MKC0023-Dec-10 2:39 
AnswerRe: Read data using assembly Pin
Rajesh R Subramanian3-Dec-10 2:50
professionalRajesh R Subramanian3-Dec-10 2:50 
GeneralRe: Read data using assembly Pin
MKC0023-Dec-10 3:45
MKC0023-Dec-10 3:45 
GeneralRe: Read data using assembly Pin
Rajesh R Subramanian3-Dec-10 3:53
professionalRajesh R Subramanian3-Dec-10 3:53 
GeneralRe: Read data using assembly Pin
MKC0023-Dec-10 22:09
MKC0023-Dec-10 22:09 
AnswerRe: Read data using assembly Pin
Aescleal3-Dec-10 6:17
Aescleal3-Dec-10 6:17 
GeneralRe: Read data using assembly Pin
MKC0023-Dec-10 22:10
MKC0023-Dec-10 22:10 
GeneralRe: Read data using assembly Pin
Emilio Garavaglia4-Dec-10 10:22
Emilio Garavaglia4-Dec-10 10:22 
JokeRe: Read data using assembly Pin
Luc Pattyn4-Dec-10 12:02
sitebuilderLuc Pattyn4-Dec-10 12:02 
QuestionMemory checker and error detector for C++ Pin
Ahmed Charfeddine3-Dec-10 1:38
Ahmed Charfeddine3-Dec-10 1:38 
AnswerRe: Memory checker and error detector for C++ Pin
Maximilien3-Dec-10 4:19
Maximilien3-Dec-10 4:19 
QuestionGet the process ID by the application itself Pin
CodingLover2-Dec-10 23:36
CodingLover2-Dec-10 23:36 
AnswerRe: Get the process ID by the application itself Pin
User 74293382-Dec-10 23:47
professionalUser 74293382-Dec-10 23:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.