473,394 Members | 1,875 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,394 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 4095
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.