Write a C++ program that converts from meters to feet using type
conversion from built in type to class type (Create Feet class).
1 feet = 0.3 meter
If meter value is less then 30 throw an exception.
Store each value in receptive files, Meters.txt and Feet.txt and display
each value as per user selection.
#include <iostream>
using namespace std;
class Feet
{
private:
int feet;
int metres;
public:
void convert()
{
cout<<"Enter Metres: ";
cin>>metres;
if(metres>=30)
{
feet=metres/0.3;
cout<<"The value in feet is :"<<feet<<endl;
}
else
{
cout<<"The value entered is less than 30 metres"<<endl;
}
}
};
int main()
{
Feet f;
f.convert();
return 0;
}
Comments
Leave a comment