Apr 8, 2014 at 9:34pm UTC
This is supposed to be pretty straight forward, but I can not seem to see what my problem is. HELP?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double choice;
cout << "pick a number between 1 and 20" << endl;
cin >> choice;
cout << endl;
if (choice > 20 && choice < 0)
{
cout << "Please select another number between 1 and 20." << endl;
}
else
{
choice = choice / 3.0;
cout << choice << endl;
}
system("pause" );
return 0;
}
It always runs the else statement n matter the input. What might be my solution?
Last edited on Apr 8, 2014 at 9:36pm UTC
Apr 8, 2014 at 9:40pm UTC
if (choice > 20 && choice < 0)
This condition is impossible.
choice cannot be both greater than 20 and less than 0.
You probably meant || (or)
Last edited on Apr 8, 2014 at 9:41pm UTC
Apr 8, 2014 at 9:49pm UTC
AH yes I see this, thank you. Further more how could I have my if statement continually ask for "another number between 1 and 20" if the user continually inputs invalid responses?