Click here to Skip to main content
15,892,298 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Connectivity with data base Pin
KingsGambit11-Jan-10 20:44
KingsGambit11-Jan-10 20:44 
QuestionMFC - CAsyncSocket class Pin
liz311-Jan-10 17:31
liz311-Jan-10 17:31 
AnswerRe: MFC - CAsyncSocket class Pin
Naveen11-Jan-10 18:39
Naveen11-Jan-10 18:39 
AnswerRe: MFC - CAsyncSocket class Pin
Cool_Dev11-Jan-10 19:21
Cool_Dev11-Jan-10 19:21 
GeneralRe: MFC - CAsyncSocket class Pin
liz311-Jan-10 21:56
liz311-Jan-10 21:56 
GeneralRe: MFC - CAsyncSocket class Pin
Moak11-Jan-10 22:37
Moak11-Jan-10 22:37 
GeneralRe: MFC - CAsyncSocket class Pin
liz312-Jan-10 19:03
liz312-Jan-10 19:03 
QuestionC++ CODE FOR VENDING MACHINE Pin
queenzz11-Jan-10 16:19
queenzz11-Jan-10 16:19 
Hi,
i have this assignment and i would like some help with it please. It is my first assignment ever in c++ and it is my first go at writing code for it. Ill post the question and my code so far if anyone could help me get the code correct and working would be really great.

Question:
Your program should operate continuously with a list of drinks and their costs displayed on screen. there should also be a "shutdown" option with a password for a service person to come and re-stock the machine.

Once a user has selected their drink the system should allow them to enter the amount of money they are inserting into the machine. The program should then calculate the amount of change to be returned and subtract one from the number of the drink in the machine. If the user selects a drink which has sold out an appropriate message should be displayed. Some input validation should be carried out on the amount eg. no negative values and no amount larger than $10.
When the "Shutdown" option is chosen the system should report total turnover and number of each drink left in the machine. After a suitable input from the service person the system should then reset the number of drinks back to the initial values and resume normal operation.

Arrays must be used and an expected looping menu-structure.

the drinks are:
coca cola...$1.50....30 (in machine)
sprite........$1.60....30
fanta.........$1.70....30
ginger beer...$1.90.....30
powerade.....$3.50.....20


And this is what i have done so far. It's all mixed up but please forgive me as its my first go. Please help me if you can?



//
//
#include <iomanip>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
const int SIZE = 5; // Array size.


struct drink_machine
{
string drinkName ;
double drinkCost;
int numDrink;
double buyDrink;

float moneyIn;
float moneyOut;
int drinks ;
int inputMoney;
double choice;
};
struct drink_machine drink_mach[SIZE];

int main()
{
int menuChoice=1, choice;


drink_mach[0]= "Coca Cola";
drink_mach[1]= "Sprite";
drink_mach[2]= "Fanta";
drink_mach[3]= "Ginger Beer";
drink_mach[4]= "Powerade";

while(menuChoice != 6)
{
cout << "Choose A Drink To Purchase: " << endl;
cout << "1 - Coca Cola" << endl;
cout << "2 - Sprite" << endl;
cout << "3 - Fanta" << endl;
cout << "4 - Ginger Beer" << endl;
cout << "5 - Powerade" << endl;
cout << "6 - Quit\n" << endl;
choice = menuChoice;
}

return 0;
}
AnswerRe: C++ CODE FOR VENDING MACHINE Pin
Richard MacCutchan12-Jan-10 0:45
mveRichard MacCutchan12-Jan-10 0:45 
QuestionRe: C++ CODE FOR VENDING MACHINE Pin
David Crow12-Jan-10 3:14
David Crow12-Jan-10 3:14 
QuestionDetecting whether a modal dialog has displayed Pin
Kenneth Ballard11-Jan-10 13:52
Kenneth Ballard11-Jan-10 13:52 
AnswerRe: Detecting whether a modal dialog has displayed Pin
KingsGambit11-Jan-10 19:02
KingsGambit11-Jan-10 19:02 
GeneralRe: Detecting whether a modal dialog has displayed Pin
Kenneth Ballard12-Jan-10 5:04
Kenneth Ballard12-Jan-10 5:04 
QuestionHelp on error Pin
siyuanfang11-Jan-10 6:52
siyuanfang11-Jan-10 6:52 
AnswerRe: Help on error Pin
Nelek11-Jan-10 6:58
protectorNelek11-Jan-10 6:58 
QuestionRe: Help on error Pin
CPallini11-Jan-10 7:00
mveCPallini11-Jan-10 7:00 
AnswerRe: Help on error Pin
Nelek11-Jan-10 7:12
protectorNelek11-Jan-10 7:12 
GeneralRe: Help on error Pin
CPallini11-Jan-10 7:32
mveCPallini11-Jan-10 7:32 
JokeOT Pin
Nelek11-Jan-10 7:39
protectorNelek11-Jan-10 7:39 
GeneralRe: OT Pin
CPallini11-Jan-10 7:43
mveCPallini11-Jan-10 7:43 
GeneralRe: OT Pin
Cedric Moonen11-Jan-10 7:55
Cedric Moonen11-Jan-10 7:55 
GeneralRe: OT Pin
CPallini11-Jan-10 7:59
mveCPallini11-Jan-10 7:59 
AnswerRe: Help on error Pin
Richard MacCutchan11-Jan-10 8:44
mveRichard MacCutchan11-Jan-10 8:44 
JokeHey Richard Pin
CPallini11-Jan-10 8:53
mveCPallini11-Jan-10 8:53 
GeneralRe: Hey Richard Pin
Richard MacCutchan11-Jan-10 8:58
mveRichard MacCutchan11-Jan-10 8:58 

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.