### I can't find the problem.

Hey everyone, I'm having to write a program that allows the user to input a certain amount of feet and Inches and then have it converted to meters and centimeters. I was wondering if anyone could help me fix this mess I've made?

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748`` ``````# include using namespace std; void input(double &feet, double &inches); void conversion (double feet, double &inches, int &meters, double ¢imeters); void output(int meters, double centimeters); int main () { int meters; double feet, inches, centimeters; char menu; do { cout << "Do You Want To Continue?(Y/N): "; cin >> menu; input(feet, inches); conversion(feet, inches, meters, centimeters); output (meters, centimeters); }while (menu == 'Y' || menu == 'y'); } void input(double &feet, double &inches) { cout << "Enter number of feet: "; cin >> feet; cout << "Enter number of inches: "; cin >> inches; } void conversion (double feet, double &inches, int &meters, double ¢imeters) { inches += 12 * feet; centimeters = inches * 2.54; meters = centimeters/100; centimeters -= meters*100; } void output (int meters, double centimeters) { cout << meters << " meters and " << centimeters << "cm " << endl; } return 0: }``````
Just out of curiosity, what is the problem you're referring to?
It seems like it's hung up on the "meters conversion," which I don't exactly understand why.
The problem I see (which may not be the one you are asking about), is the question "Do You Want To Continue?(Y/N): ". Regardless of the answer, the program then requests the feet and inches, and prints the result.

Only after doing that does it get around to testing the answer (y or n) to the question. One way around this is to ask that question just before the end of the loop, not just at the beginning.

How you handle this really depends on what is the required behaviour of the program.
Last edited on
Thank you Chervil. That makes sense to me, I appreciate you pointing that out.
Topic archived. No new replies allowed.