I need help with the source code that I am going to attach. I have all of the pieces but I cannot figure out to put the pieces together.
I am to ( 1) have a display showing denominations of money accepted, total amount deposited, price of a soda, and a coin return that shows coins rejected (like pennies), and change returned by denomination (two dimes and one nickel, for example).
(2) the program should dispense a soda when an adequate deposit has been made.
(3) the program should repeat until told to quit.
(4) as with real soda machines, it should randomly take a customers money without dispensing a soda.
I can improve/improvise on the basics for extra credit.
This program is due no later than Oct 25, 2004.
Please I need help. This is the code that I have been trying to get to work for days now and I can't get it to work.
Please send me any help and source code so that I can finish this project. My lab teacher does not give us a lot of instruction on different programs, he only gives us a few examples and expects us to do the rest.
Thanks for any help and source code,
Jeannette
#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;
int main()
{
int sum;
cout << "Enter coin: \t";
cin >> deposit;
deposit++;
sum = coke();
// display();
// takemoney();
// buy();
// cout <<"Do you want to continue to buy another drink?" << endl;
// cin >> flag;
return 0;
}
// display function
// displays the screen for buying a drink
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();
// money += deposit;
// slot += deposit;
// rejected -= deposit;
// int 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;
//
// reject();
}
// function for entering money and status of money
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;
}
// if ( deposit == .50 )
// {
// ++money;
// cout << "Deposit more money!" << endl;
// }
// if ( deposit == .75 )
// {
// ++money;
// cout << "Deposit more money!" << endl;
// }
return deposit;
}
// function to reject money
int reject()
{
double rejected = 0;
double slot;
if ( deposit > .01 || deposit < .05 )
{
money = 0;
deposit = 0;
slot = rejected;
// rejected -= deposit;
cout << "WRONG AMOUNT, ENTER CORRECT COINS!" << endl << endl;
}
return slot;
}
// function for taking money and giving no drink
void takemoney( void )
{
money = rand() % 5;
if ( money == .50 )
money = 0;
cout << "Lost money" << endl;
cout << "No drink" << endl;
}
// function to continue buying a drink
int buy()
{
// int sum;
char flag = 'N';
int N = 0;
if ( flag == 'Y' || flag == 'y' )
// cout << "Enter deposit to continue: ";
// cin >> flag;
coke();
return flag;
}