I need help making a program that include meter yards and feet. my c+ class is only in chapter 4 of the c++ book.

void convertMeters(int meters)

int main
1. ask for the number of meters
2. read in the number of meters
4. the output should look like:

??? meters is:
??? inches
??? feet
??? yards
??? miles

my class program looks like this

What exactly is the problem with your program? What parts do you not understand or are having trouble with?

im thinking the protype will be void convertMeters(int meters) then int main where i am stuck on

since i am looking for 5 problem. Wouldn't i have to name my int after main be int s,r,x,y,z ; if i was tring to print out
??? meters is:
??? inches
??? feet
??? yards
??? miles

One method of attack for this problem would be to create separate functions for each conversion. You could have a function like this: `void printMetersAsFeet(int meters);` It would perform the conversion and display the results. You could then adapt this function to perform the other conversions required of you.

so far I think I have this

``````**************************************
*     libraries
***************************************/
#include <iostream>                       // needed for cin/count
#include <cmath>                         // needed for math functions
using namespace std;

/****************************
*    prototypes    //declared function so main can find
*****************************/
void convertMeters(int meters)

int main()
}
int s,r,x,y,z;``````

wouldn't i have to define the var. next?

I don't know what you're planning on using those variables at the bottom of your program, but most likely you won't need them.

What you need to do next is to create the body of convertMeters(). You'll want a few statements that print out what the specified number of meters is in a few different formats. For example: `printf("%d meters is %f feet.\n", meters, meters*3.2808);`

thanks for helping I figure it out I made it look like this

``````void convertMeters(int meters);

int main()
{
int meters;
cout << "Amount: ";
cin >> meters;
convertMeters(meters);

system("pause");
}
void convertMeters(int meters)
{
double inches = meters / .254;
double feet = meters / .3048;
double yards = meters / .9144;
double miles = meters / 1609.344;

//std::cout.setf(std::ios_base::fixed, std::ios_base::floatfield);
//std::cout.precision(3);

std::cout << meters << " meters is: \n   "
<< inches << " inches \n  "
<< feet    << " feet \n  "
<< yards  << " yards  \n  "
<< miles  << " miles \n  ";
}``````
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.