# Thread: Help with C++! Feet and inches to meters and centimeters and vice versa program

1. ## Help with C++! Feet and inches to meters and centimeters and vice versa program

So I've set up the if else and loop for the program. I've hit a brick wall with the conversions. Let's say i enter 5 feet and 4 inches. I need it to say 1 meters and 62.56 centimeters and vice versa when i do the other option. How do I do coding for the necessary calculations for the output?? Please help.. I am a beginner and just started taking a course at school.

Code:
```#include<iostream>
using namespace std;
void main()
{
int choice;
do
{
float ft,in,m,cm;

cout<<"1.Convert Feet and Inches to Meters and Centimeters."<<endl;
cout<<"2.Convert Meters and Centimeters to Feet and Inches."<<endl;
cout<<"Enter 0 to end program."<<endl;
cin>>choice;
if (choice==1)
{
cout<<"Enter Feet: ";
cin>>ft;
cout<<"Enter Inches: ";
cin>>in;
cout<<"The total feet and inches in meters and centimeters is "<<()<<"m and "<<()<<"cm."<<endl;
cout<<" "<<endl;
}
else if (choice==2)
{
cout<<"Enter Meters: ";
cin>>m;
cout<<"Enter Centimeters: ";
cin>>cm;
cout<<"The total meters and centimeters in feet and inches is "<<()<<" ft and "<<()<<" in."<<endl;
cout<<" "<<endl;
}
}
while(choice!=0);

if(choice==0)
cout<<"Program Ended."<<endl;
}```

2. << !! Posting Code? Read this First !! >>
SourceForge.net: Void main - cpwiki
And then ask a specific question. What is it that you don't understand?

3. Originally Posted by Elysia
<< !! Posting Code? Read this First !! >>
SourceForge.net: Void main - cpwiki
And then ask a specific question. What is it that you don't understand?
Edited! sorry bout that

4. I'm assuming you want to use some functions to do this, and that's much better than trying to code it inline. I'm guessing you haven't done classes yet, so I'd make several functions:

convertFeetInchesToInches
convertInchesToFeetInches
convertMetersCentimetersToCentimeters
convertCentimetersToMetersCentimeters

and

convertInchesToCentimeters
convertCentimetersToInches

5. Originally Posted by ricefangiez
Edited! sorry bout that
You still haven't fixed void main.
But you say you don't understand how to make the calculations. But what do you not understand, exactly? Do you know how convert inches to meters, for example? Do you know how to perform arithmetic operations on variables (ie add one to a variable)?

6. got it to work! on my own!

7. Originally Posted by Elysia
You still haven't fixed void main.
But you say you don't understand how to make the calculations. But what do you not understand, exactly? Do you know how convert inches to meters, for example? Do you know how to perform arithmetic operations on variables (ie add one to a variable)?
i dont need to fix the void main(). sorry i'm very limited as the class just started last week

8. You need to fix void main because it's not standard.
But it's nice to hear you solved it.

9. Originally Posted by Elysia
You need to fix void main because it's not standard.
But it's nice to hear you solved it.
really? thats the way the professor has been doing it... Bleh lol

10. Many professors are, and I shall put it bluntly, idiots. Others are merely ignorant.
Feel free to point out to your professor that void main is non-standard and tell him C++ experts have told you so.

11. We should we all strive to be as correct as possible. I mean, using int main() isn't really a trivial matter of taste or style, it's the correct way to do it. It just seems strange to me that a professor would teach others the wrong way to do something.

12. Originally Posted by micahharwell
We should we all strive to be as correct as possible. I mean, using int main() isn't really a trivial matter of taste or style, it's the correct way to do it. It just seems strange to me that a professor would teach others the wrong way to do something.
well it's not wrong.. just not standard apparently because I can still get my program to run with that. I'll ask tomorrow :T

13. Originally Posted by micahharwell
We should we all strive to be as correct as possible. I mean, using int main() isn't really a trivial matter of taste or style, it's the correct way to do it. It just seems strange to me that a professor would teach others the wrong way to do something.
Some professors are ignorant. They think they are right, but they don't know they're wrong. C++ is a huge language and there are a lot of details, so even experts don't know it all.
Other professors are just pure idiots. They think they are right and everyone else is wrong and refuse to listen to reason.

Originally Posted by ricefangiez
well it's not wrong.. just not standard apparently because I can still get my program to run with that. I'll ask tomorrow :T
It is wrong. C++ is language defined by a standard. Something that isn't written in the standard isn't part of the language. And nowhere in the standard says there is a void main.
It is wrong of the compilers to allow non-standard constructs.