#include<iostream.h>
#include<conio.h>
class f2c
{
private:
float c,f;
public:
void getdata(float x)
{
f=x;
c=0;
}
void convert()
{
c=(f-32)*100/180;
}
void display()
{
cout<<"celsius is:"<<c;
}
};
class c2f
{
private:
float c,f;
public:
void getdata(float x)
{
c=x;
f=0;
}
void convert()
{
f=(c)*180/100;
}
void display()
{
cout<<"cfarenheit is:"<<f;
}
};
int main()
{
cout<<"1.conversion of farenfeit to celsuis:"<<endl;
cout<<"2.conversion of celsius to farenheit:"<<endl;
int choice;
cout<<"enter your choice:"<<endl;
cin>>choice;
switch(choice)
{
case 1:
f2c A;
float x;
cout<<"enter farenheit:"<<endl;
cin>>x;
A.getdata(x);
A.convert();
A.display();
break;
case 2:
c2f B;
float y;
cout<<"enter celsius:"<<endl;
cin>>y;
B.getdata(y);
B.convert();
B.display();
break;
default:
cout<<endl<<"wrong entry:";
break;
};
getch();
return(0);
}
No comments:
Post a Comment