473,545 Members | 2,095 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to print report vending machine using c++

1 New Member
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<iomani p>
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(i nt&,float&);
float Get_Money(float &);
float Get_Change(floa t,float);
void Write_Change(fl oat);
void Write_Report_Ca sh_Out(const int coins[]);
void Write_Report_Dr inks(const int coins[]);
void Write_Report_Ca sh_In();



int main(int argc, char *argv[])
{
int selection=0;
float price;
float money;
float change;
while(selection !=6)
{
Write_Menu();
Get_Selection(s election,price) ;
if(selection<5) {
money=Get_Money (gCash);
change=Get_Chan ge(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<<"**"<<end l;
cout<<"*VENDING MACHINE*"<<endl ;
cout<<"**"<<end l;
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<<"*Termina te\t\t- Press 6*"<<endl;
cout<<"**"<<end l;
cout<<"******** *************** ************"<< endl;
}

void Get_Selection(i nt&selection,fl oat&price)
{
cout.setf(ios:: fixed);
cout.setf(ios:: showpoint);
cout.precision( 2);

cout<<"Please enter your selection."<<en dl;
cout<<"Then press Enter."<<endl;
cout<<"Your selection>";
cin>>selection;
switch(selectio n)
{
case 1:
cout<<"You chose Teh Tarik-"<<TEH_TARIK<<e ndl;
price=gPrice[TEH_TARIK];
cout<<"The price RM:"<<price<<en dl;
break;
case 2:
cout<<"You chose Nescafe-"<<NESCAFE<<end l;
price=gPrice[NESCAFE];
cout<<"The price RM:"<<price<<en dl;
break;
case 3:
cout<<"You chose HORLICK-"<<HORLICK<<end l;
price=gPrice[HORLICK];
cout<<"The price RM:"<<price<<en dl;
break;
case 4:
cout<<"You chose Teh O-"<<TEH_O<<e ndl;
price=gPrice[TEH_O];
cout<<"The price RM:"<<price<<en dl;
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<<en dl;
}
}
float Get_Money(float &cash)
{
float money,money1,mo ney2,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+mo ney2+money3;


return money;
}

float Get_Change(floa t 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(fl oat 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 4106
JosAH
11,448 Recognized Expert MVP
@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
6377
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 want. I am trying to open MSAccess from ASP..I guess I would use server.createobject("Access.Application") OK, but where do i go from there to...
1
4019
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 the item and after that tell him to enter the coins.
9
3998
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 for the cash register and the other for the dispenser), and 2 member function definitions .cpp (one for each). It is a little lengthy, and there are...
7
14814
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 should have two classes, one for the vending machine(VM) and the other for drinks. The capacity of the VM is specified on creation. The drinks can be...
1
6981
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 Labels that indicate numbers for each snack. I need to use a string array that contains the names of each snack. The GUI should contain a TextBox in...
18
4467
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 on the report server. See the error log for more details. Do I have something configured wrong? I do not knw where to find the error log to review...
10
9100
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. The access 2007 users cannot print one of the reports. This is maddening since I cannot duplicate the issue on any computer that runs 2003 or below....
3
2974
by: ismaeel | last post by:
i very need for intrfase of vending machine for netbense sending to email plese
3
7604
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 when they shouldn't be. For instance, I choose my items, and it asks me if I want to pay with 1 debit or 2 credit. If I enter 3 it displays 'Invalid...
0
7464
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7396
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7413
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7751
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4943
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3440
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1874
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
700
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.