Conversion Chart

I need some help with this program that converts inches to centimeters.. I pretty much have the program all figured out except for one detail.. when the user inputs the low inch value, the high inch value they enter next cannot be more than 36 of the low value. How can i get the program to display an error message and ask the user to input a number only 36 larger or less than the low value?

int main ()

{

//No Local constants
double counter = 0; //While Loop counter
char RunAgain = 'Y'; //ask to run program again

//Local variables
int beginValue; //beginning value of inches
int endValue; //end value of inches
/*************** Begin main Function Executables *****************/

//Clear the screen
system ("cls");

while (RunAgain == 'y' || RunAgain == 'Y')//program runs again if y, Y entered
{

cout << "Enter low INCH value: ";//asks user to input low range value
cin >> beginValue;//store low range value

cout << "Enter high INCH value: ";//asks user to input high range value
cin >> endValue; //store high range value

if ((beginValue / 6) > 1)
{
beginValue = beginValue - (beginValue / 6);//intervals of 6
}

cout << "\n" << setw(8) << "Inches" << setw(21) << "Centimeters" <<
"\n" << "**********" << setw(20) << "*************";//conversion table

while (endValue > beginValue)
{
counter = beginValue * 2.54;//inches to centimeters conversion
cout << "\n" << setw(5) <<
beginValue << setw(21) << fixed << showpoint << setprecision(2) <<
counter;//information on conversion table
beginValue = beginValue + 6;//intervals of 6
endValue <= beginValue + 36;
}

cout << "\n\nRun Again? ";
cin >> RunAgain;

}

return 0;
}// end main
You can check for the condition,
if((beginValue - endValue) > 36)
cout<<"error";


immediately after taking both input.
Last edited on
thanks.. it prints out error, but continues to print out the information after... i want it to print out error and loop back to asking for the inputs again... any suggestions?
this might be helpful to you but i am not sure..

if((beginValue - endValue) > 36)
{
    cout<<"error";
    continue;
}

let me know if this won' work.
Topic archived. No new replies allowed.