Need help with a loop program

The object here is to allow a user to enter a measurement, then tell us whether it is feet or inches. The program should convert feet to inches or vice versa and keep doing it until the user enters a sentinel value of 0 to end the program.

What I have now compiles but once I enter a 1 or 2 (for feet or inches) the program stops and wont continue. Can anyone help out?

Thanks




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[//Enter a measurement in either feet or inches.
     cout << "Enter a measurement in either feet or inches: "; cin >> measurement;
     cout << endl;
     
     //Enter a 1 for feet or a 2 for inches.
     cout << "Enter a 1 if you used feet or 2 if you used inches : "; cin >> one >> two;
     cout << endl;  
     
     //Calculate feet to inches and inches to feet and loop when 0 is not entered
     measurementfeet = measurement * 12;
     measurementinches = measurement / 12;
{     if (one || two < 0);
         cout << "Feet or inches cannot be negative";
      if (one == true);
        return measurement = one; // assigning measurement to 1 if 1 is entered
      if (two == true);
        return measurement = two; // assigning measurement to 2 if 2 is entered 
]
I do believe that your first if statement is wrong. It should be.

1
2
3
if ( (one < 0) || (two <0) )
{
// your stuff goes here 


because in your code your asking if "one" is true when you should be asking is "one less than zero" true
Topic archived. No new replies allowed.