By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,640 Members | 1,557 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,640 IT Pros & Developers. It's quick & easy.

how to print report vending machine using c++

P: 1
i've already build a program that contain all the price, the change given back to the customer but i dun have no idea which function i should use to do program print report...

#include <cstdlib>
#include <iostream>
#include<iomanip>
using namespace std;
const int TEH_TARIK = 0;
const int NESCAFE = 1;
const int HORLICK = 2;
const int TEH_O = 3;
float gPrice[4]={1,1.1,1.2,.9};
int gDrinks[4]={0,0,0,0};
int gCoins[4]={0,0,0,0};
float gCash=0;
void Write_Menu();
void Get_Selection(int&,float&);
float Get_Money(float&);
float Get_Change(float,float);
void Write_Change(float);
void Write_Report_Cash_Out(const int coins[]);
void Write_Report_Drinks(const int coins[]);
void Write_Report_Cash_In();



int main(int argc, char *argv[])
{
int selection=0;
float price;
float money;
float change;
while(selection !=6)
{
Write_Menu();
Get_Selection(selection,price);
if(selection<5){
money=Get_Money(gCash);
change=Get_Change(money,price);

}
}

system("PAUSE");
return EXIT_SUCCESS;
}

void Write_Menu()
{
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout<<""<<endl<<endl;
cout<<"***************************"<<endl;
cout<<"**"<<endl;
cout<<"*VENDING MACHINE*"<<endl;
cout<<"**"<<endl;
cout<<"*Teh Tarik\t-"<<gPrice[TEH_TARIK]<<"\t-Press 1"<<endl;
cout<<"*Nescafe\t-"<<gPrice[NESCAFE]<<"\t-Press 2"<<endl;
cout<<"*Horlick\t-"<<gPrice[HORLICK]<<"\t-Press 3"<<endl;
cout<<"*Teh'O'\t\t-"<<gPrice[TEH_O]<<"\t-Press 4"<<endl;
cout<<"*Print Report\t\t- Press 5*"<<endl;
cout<<"*Terminate\t\t- Press 6*"<<endl;
cout<<"**"<<endl;
cout<<"***********************************"<<endl;
}

void Get_Selection(int&selection,float&price)
{
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);

cout<<"Please enter your selection."<<endl;
cout<<"Then press Enter."<<endl;
cout<<"Your selection>";
cin>>selection;
switch(selection)
{
case 1:
cout<<"You chose Teh Tarik-"<<TEH_TARIK<<endl;
price=gPrice[TEH_TARIK];
cout<<"The price RM:"<<price<<endl;
break;
case 2:
cout<<"You chose Nescafe-"<<NESCAFE<<endl;
price=gPrice[NESCAFE];
cout<<"The price RM:"<<price<<endl;
break;
case 3:
cout<<"You chose HORLICK-"<<HORLICK<<endl;
price=gPrice[HORLICK];
cout<<"The price RM:"<<price<<endl;
break;
case 4:
cout<<"You chose Teh O-"<<TEH_O<<endl;
price=gPrice[TEH_O];
cout<<"The price RM:"<<price<<endl;
break;
case 5:
cout<<"print report"<<endl;
break;
case 6:
price = 0;
break;
default:
price = 0;
cout<<"You must enter a selection between 1 and 6. Thank You!"<<endl<<endl;
}
}
float Get_Money(float&cash)
{
float money,money1,money2,money3;

cout<<"Please enter the RM amount"<<endl;
cin>>money1;
cin>>money2;
cin>>money3;


if(money<2.00)
{
cout<<" MONEY " << endl;
}
else if(money=gPrice[TEH_TARIK])
{
cout<<"TEH TARIK"<<endl;
}
else if(money=gPrice[NESCAFE])
{
cout<<"NESCAFE"<<endl;
}
else if(money=gPrice[HORLICK])
{
cout<<"HORLICK"<<endl;
}
else if(money=gPrice[TEH_O])
{
cout<<"TEH O"<<endl;
}
money=money1+money2+money3;


return money;
}

float Get_Change(float money,float price)
{
float change;

if(money<price)
{
change = money - price;
cout<< " your spending "<< money <<endl;
cout<< " insert the money "<< change <<endl;
}
else

cout<< "You are spending "<< money <<" Then Press Enter "<<endl;

change = money - price;
cout<<" BALANCE "<<change<<endl;


return change;
}

void Write_Change(float change)

{

/////i'm stucked here how to build print report...
system("PAUSE");
return EXIT_SUCCESS;

}


could u gave me an idea as soon as possible...
Mar 23 '09 #1
Share this Question
Share on Google+
1 Reply


Expert 10K+
P: 11,448
@OP: I moved your post to its own thread because you were hijacking someone else's thread which is considered rude.

kind regards,

Jos (moderator)
Mar 23 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.