i haven done it but it will help what i have done
#include <iostream>
#include <iomanip>
#include <conio.h>
#include <cstdlib>
// #include <cmath>
using std::setprecision;
using std::setw;
using std::cin;
using std::cout;
using std::endl;
using std::fixed;
char flag = 'N';
void display();
int coke();
int reject();
void takemoney ( void );
int buy();
int deposit = 0;
double coinreturn;
int money;
void main()
{
display();
takemoney ( );
int sum;
cout << "Enter coin: \t";
cin >> deposit;
deposit++;
sum = coke();
}
void display()
{
double slot = 0;
double rejected = 0;
double money = 0;
double deposit = 0;
// int sum;
cout << "\t\t **********************" << endl;
cout << "\t\t\tSODA MACHINE" << endl;
cout << "\t\t **********************" << endl << endl;
cout << "Soda $1.00" << endl << endl;
cout << "Money accepted: Dollar, Quarters, Dimes, Nickels"
<< endl;
cout << "\t\t($1.00)\t (.25)\t (.10)\t (.05)" << endl << endl;
cout << "Enter coin: \t";
cin >> deposit;
coke();
cout << "Total Amount Deposited: \t\t" << fixed << setprecision ( 2 ) << money << endl;
cout << "Slot: \t" << fixed << setprecision ( 2 ) << slot << endl;
cout << "Coin return: \t" << endl;
}
int coke()
{
double deposit = 0;
double money = 0;
if ( deposit == 1.00 )
{
++money;
cout << "You have deposited the correct amount!" << endl;
cout << "Here is your soda!" << endl;
}
if ( deposit == .05 )
{
++money;
cout << "Deposit more money!" << endl;
}
if ( deposit == .10 )
{
++money;
cout << "Deposit more money!" << endl;
}
if ( deposit == .25 )
{
++money;
cout << "Deposit more money!" << endl;
}
return deposit;
}
int reject()
{
double rejected = 0;
double slot;
if ( deposit > .01 || deposit < .05 )
{
money = 0;
deposit = 0;
slot = rejected;
cout << "WRONG AMOUNT, ENTER CORRECT COINS!" << endl << endl;
}
return slot;
}
void takemoney( void )
{
money = rand() % 5;
if ( money == .50 )
money = 0;
cout << "Lost money" << endl;
cout << "No drink" << endl;
}
int buy()
{
char flag = 'N';
int N = 0;
if ( flag == 'Y' || flag == 'y' )
coke();
return flag;
}
email me on
yb1pls@yahoo.co.uk if you still confused