473,287 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

how to print report vending machine using c++

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
1 4087
JosAH
11,448 Expert 8TB
@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

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

Similar topics

8
by: jbonifacejr | last post by:
This is my first day here, so please be patient. I do not know how to search very well so the search I tried to get the answer showed me topics from the year 2000 and they really don't cover what I...
1
by: pradeepkumar | last post by:
give me the code for vending machine in c++. it has 10 items in a .first display all the items and its cost and its quantityonhand.then ask the customer if he wishes to buy.if yes tell him to select...
9
by: vpascuzzi | last post by:
Here's the deal: I've been working on this little program forever now, and can't seem to get the final little glitches out of it. I am to build a vending machine, using 2 header .h files (one...
7
by: JohnSmith70 | last post by:
Please help I need help with this homework. Its about vending machines, and it should be a piece of cake to you code experts out there. Its about vending machines. Heres the question: It...
1
by: Kunthea | last post by:
I am not that good at programming and I need a little push on how I can start my programming on the vending machine. The basic of the homework is that it displays four snacks and corresponding...
18
by: =?Utf-8?B?SGVyYg==?= | last post by:
I'm using a ReportViewer in ASP.NET. From the development environment it works fine. When published and I try to open the page with the ReportViewer I get the error: An internal error occurred...
10
by: Snoopy33 | last post by:
I have a DB that I developed on access XP (2002) and deployed over a year ago. No one has had problems printing any of the reports within the DB until we started loading 2007 on new computers. ...
3
by: ismaeel | last post by:
i very need for intrfase of vending machine for netbense sending to email plese
3
by: exospire | last post by:
Hello everyone, I made a program that simulates a vending machine for class. I finally got it to execute without any errors, yet something is not right. I have functions that are being called upon...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.