Write a program that produces a table converting distance in feet to distances in meters, for values of feet from 10 to 200, in steps of 10 feet. There are 39.37 inches in 1 meter, three feet in 1 yard, and 12 inches in 1 foot. You must use a loop.

I did:

``````# include <iostream>
# include <cmath>

using namespace std;

int main()
{

int i;
double inches = 39.37;
double feet = 3;
double foot = 12;
double meters = 39.37;
double yard = 3;

for (i=10; i=200; i++)
{
cout << "For values of feet from 10 to 200 are: " << feet << inches << foot << meters << yard << endl;
cin >> feet, inches, foot, meters, yard;
char feet;
break;
}

while (i<=200)
{
cout << "The conversion is " << endl;
}

return 0;
}``````

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

2
Contributors
1
2
Views
8 Years
Discussion Span
Last Post by abhimanipal

See the objective of the program is to convert from feet to meters. If you use the information that is given in the problem statement ... you see that
10 feet = 12 inches
1 inch= 1/39.37 metres
Therefore
10feet= 12*(1/39.37)metres

Now the program says that accept the input from the user. The user enters the value of feet. This value should be between 10 and 200. So when the user enters the input use a if condition to check if the value is indeed between 10 and 200.

If it is you use a loop to do the conversion. For example, if the user enters 30 feet, this contains 3 10 feets. Initialize a variable to 0. Add 12*(1/39.37) 3 times to the variable.