B
bd
I think that I can convey my problem without having to post the entire
code.
I know that I am doing this wrong and that there is a better way, but
I keep coming up short with my various methods....
Here is the code:
//
************************************************************************************************
void getItems( /*inout*/ char& woodLetter,
/*inout*/ int& quantity,
/*inout*/ int& width,
/*inout*/ int& height,
/*inout*/ int& length )
// Postcondition: woodLetter must equal P, F, C, M, O, or T
{
bool exit;
exit = false;
cout << "\nEnter items: ";
cin >> woodLetter >> quantity >> width >> height >> length;
woodLetter = toupper(woodLetter);
if ((woodLetter=='P')||
(woodLetter=='F')||
(woodLetter=='C')||
(woodLetter=='M')||
(woodLetter=='O')||
(woodLetter=='T'))
exit = true;
while(exit==false);
{
cout << "\nWood Type must be one of the following:"
<< "\n(P) - Pine"
<< "\n(F) - Fir"
<< "\n(C) - Cedar"
<< "\n(M) - Maple"
<< "\n(O) - Oak"
<< "\n(T) - Total Price"
<< "\n\nEnter item: ";
cin >> woodLetter >> quantity >> width >> height >> length;
woodLetter = toupper(woodLetter);
if (woodLetter=='P')
exit = true;
else if (woodLetter=='F')
exit = true;
else if (woodLetter=='C')
exit = true;
else if (woodLetter=='M')
exit = true;
else if (woodLetter=='O')
exit = true;
else if (woodLetter=='T')
exit = true;
else exit = false;
}
return;
}
//
************************************************************************************************
This is not working for me. It will compile, but when I input what
should be one of the correct chars in upper or lower case, the program
still goes to the while loop and I get prompted again.
Any ideas?
Thanks,
Dale
code.
I know that I am doing this wrong and that there is a better way, but
I keep coming up short with my various methods....
Here is the code:
//
************************************************************************************************
void getItems( /*inout*/ char& woodLetter,
/*inout*/ int& quantity,
/*inout*/ int& width,
/*inout*/ int& height,
/*inout*/ int& length )
// Postcondition: woodLetter must equal P, F, C, M, O, or T
{
bool exit;
exit = false;
cout << "\nEnter items: ";
cin >> woodLetter >> quantity >> width >> height >> length;
woodLetter = toupper(woodLetter);
if ((woodLetter=='P')||
(woodLetter=='F')||
(woodLetter=='C')||
(woodLetter=='M')||
(woodLetter=='O')||
(woodLetter=='T'))
exit = true;
while(exit==false);
{
cout << "\nWood Type must be one of the following:"
<< "\n(P) - Pine"
<< "\n(F) - Fir"
<< "\n(C) - Cedar"
<< "\n(M) - Maple"
<< "\n(O) - Oak"
<< "\n(T) - Total Price"
<< "\n\nEnter item: ";
cin >> woodLetter >> quantity >> width >> height >> length;
woodLetter = toupper(woodLetter);
if (woodLetter=='P')
exit = true;
else if (woodLetter=='F')
exit = true;
else if (woodLetter=='C')
exit = true;
else if (woodLetter=='M')
exit = true;
else if (woodLetter=='O')
exit = true;
else if (woodLetter=='T')
exit = true;
else exit = false;
}
return;
}
//
************************************************************************************************
This is not working for me. It will compile, but when I input what
should be one of the correct chars in upper or lower case, the program
still goes to the while loop and I get prompted again.
Any ideas?
Thanks,
Dale