Answer to Question #256904 in C++ for dhruv oza

Question #256904

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.


1
Expert's answer
2021-10-26T07:09:02-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS