plz chk my code to do currency conversion

# include <iostream.h>
# include <conio.h>

main ()
{

cout<<"Wellcome To VU Money changer";
cout<<"\n";

// data type initillizing

char con,coninto,op;
float amount;
do
{

//discription print message on consol what program contains

cout<<"Please select currencies that you want to Exchange :"<<endl;
cout<<"\n"<<"Discription:"<<endl;
cout<<"\n";
cout<<"\t"<<":***********************************************:"<<endl;
cout<<"\t"<<": Press 'R' & hit Enter For Pakistani Rupees    :"<<endl;
cout<<"\t"<<": Press 'E' & hit Enter For British Euro        :"<<endl;
cout<<"\t"<<": Press 'D' & hit Enter For United Stats Doller :"<<endl;
cout<<"\t"<<":***********************************************:"<<endl;
cout<<"\n";

/* Here consol prompt the user to enter name of currency that He/She
wants to change. And con stands for converting value */

cout<<": Please Enter curuncy that you want to change  :";
cin>>con;
cout<<"\n";

/* Here consol print a message for user to enter the command to
converting value wich He/She wants. coninto stands for convert into */

cout<<": Please Enter curuncy that you want to exchange:";
cin>>coninto;
cout<<"\n";

/* Here console will show a message for the user to enter amount
that He/she wants to convert */

cout<<": Please Enter amount that you want to change   :";
cin>>amount;
cout<<"\n";

// initilizing float data type

float value,camount;

/* float data type (value) contains the currency rate and float data type
( camount ) contans the value after calculating and then print message.
 camount stands for changed amount*/

if ((con=='R' || con=='r') && (coninto=='d' || coninto=='D'))
{

// This section is for converting Pakistani Rupees into US Dollers

value=84;
camount=amount/value;
cout<<"\n";

/* Here amount shows the value that has been got in above section and 
camount shows calculating values. */

cout<<amount<<" Rupees = "<<camount<<" Doller(s)"<<endl;
}
else if ((con=='R' || con=='r') && (coninto=='E' || coninto=='e'))
{

// This section is for converting Pakistani Rupees into Euro

value=112;
camount=amount/value;
cout<<"\n";
cout<<amount<<" Rupees ="<<camount<<" Euro"<<endl;
}
else if ((con=='E' || con=='e') && (coninto=='R' || coninto=='r'))
{

// This section is for converting Euro into Pakistani Rupees

value=112;
camount=value*amount;
cout<<amount<<" Euro ="<<camount<<" Rupees"<<endl;
}
else if ((con=='D' || con=='d') && (coninto=='R' || coninto=='r'))
{

// This section is for converting US Dollers into Pakistani Rupees

value=84;
camount=amount*value;
cout<<amount<<" Doller(s) ="<<camount<<" Rupee(s)"<<endl;
}
else if ((con=='E' || con=='e') && (coninto=='D'|| coninto=='d'))
{

// This section is for converting Euro into US Dollers

value=1.38;
camount=amount*value;
cout<<amount<<" Euro(s) ="<<camount<<" Doller(s)"<<endl;
}
else if ((con=='D' || con=='d') && (coninto=='E' || coninto=='e'))
{

// This section is for converting US Dollers into Euro

value=0.75;
camount=amount*value;
cout<<amount<<" Doller(s) ="<<camount<<" Euro(s)"<<endl;
}
else

// If any mistake occured in currency command consol will shwos this message

cout<<" Invalid InPut enter correct command"<<endl;
cout<<"\n";

/* This the Do-While loop statment. In this statment if user wants to convert
more amount press Y the programe will restart if he pressed N then program will
end */

cout<<"Do You want to convert more [Y/N]: ";
cin>>op;
}
while (op=='Y' || op=='y');

//Ending line. This line executes in turbo c or in cmd.exe

cout<<"\n"<<"Thank you For using VU money changer";
return 0;
getch();
}

it gives the following error

5 C:\Dev-Cpp\include\c++\3.4.2\backward\iostream.h:31,               from C:\Documents and Settings\Administrator\My Documents\Downloads\Assignment (1).cpp In file included from C:/Dev-Cpp/include/c++/3.4.2/backward/iostream.h:31,               from C:\Documents and Settings\Administrator\My Documents\Downloads\Assignment (1).cpp 


5 C:\Documents and Settings\Administrator\My Documents\Downloads\Assignment (1).cpp                  from C:\Documents and Settings\Administrator\My Documents\Downloads\Assignment (1).cpp 

32:2 C:\Dev-Cpp\include\c++\3.4.2\backward\backward_warning.h #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated. 
--

Recommended Answers

All 2 Replies

your header files are incorrect;

#include <iostream.h>

You should be using this header file when it comes to c++...:P

#include <iostream>

Also you are missing

using namespace std;

Also using getch() is very bad practice you should instead use a different method...

change this :

# include <iostream.h>
# include <conio.h>
main ()

to this :

#include <iostream>
#include <string>
using namespace std;
int main ()

and instead of getch() use this :

cin.clear();
cin.ignore(256,'\n');
string pause;
getline(cin,pause);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.