13.1k views
0 votes
Going metric. (convert feet into meters) write a program that reads a number in feet, converts it to meters, and displays the result. one foot is 0.305 meters. input and prompts.the program prompts for the feet with the message "enter a value for feet: ". output . the output is of the form "x feet is y meters" where x is the number read in and y is the number of meters computed by the program . class names. your program class should be called femtometers

User SmithMart
by
7.7k points

1 Answer

3 votes
class femtometers
{
const double FEET_TO_METERS = 0.3048;
public:
double ConvertToMeters(double feet)
{
return feet * FEET_TO_METERS;
}
};


int main()
{
double feet = 0;
femtometers converter;

do {
printf("enter a value for feet: ");

scanf_s("%lf", &feet);
double meters = converter.ConvertToMeters(feet);
printf("%lf feet is %lf meters\\", feet, meters);
} while (feet > 0.0);

return 0;
}

User Gokhan Dilek
by
7.4k points