First off, The definition of else is if the previous if isn't true, therefore the && declaration thingies isn't neccesary. Next I was trying to make it if they user input something other than a number, they would still receive the message. Lastly.. Ya I do need to work on my coding.. Let me throw up my current code though instead of that.. I changed loop types
here it is:
Code:
#include <iostream>
using namespace std;
int main()
{
int books;
int input;
int i;
while ( i != 32000 )
{
cout<< i <<endl;
i++;
cout<<"How many books have you read this last year?\n";
cin>> books;
cin.ignore();
cout<<"You read "<< books <<"?\n";
if ( books >= 90 )
{
cout<<"Listed below are your options:\n";
cout<<" a : 42' Tv Set!\n";
cout<<" b : MP3 Player!\n";
cout<<" c : Sony Cd Player!\n";
cout<<" d : Book Subscription!\n";
cout<<" e : A peice of Candy!\n";
cin>> input;
if ( input == 'a' )
{
cout<<"Wow! Congratulations! You've won a 42' Tv Set!\n";
cin.get();
}
else if ( input == 'b' )
{
cout<<"Good Job! You've won an MP3 player!\n";
cin.get();
}
else if ( input == 'c' )
{
cout<<"The work paid off! You've won a Sony CD player!\n";
cin.get();
}
else if ( input == 'd' )
{
cout<<"This'll help you boost your score! Your very own National Book Club Subscription!\n";
cin.get();
}
else if ( input == 'e' )
{
cout<<"Here is some candy, maybe it will boost your brain power!\n";
cin.get();
}
else if ( input != 'a' || input != 'b' || input != 'c' || input != 'd' || input != 'e' )
{
cout<<"Error. Please enter a, b, c, d, or e\n";
cin.get();
}
cin.get();
}
else if ( books >= 75 )
{
cout<<"Listed below are your options:\n";
cout<<" b : MP3 Player!\n";
cout<<" c : Sony Cd Player!\n";
cout<<" d : Book Subscription!\n";
cout<<" e : A peice of Candy!\n";
cin>> input;
cin.ignore ();
if ( input == 'b' )
{
cout<<"Good Job! You've won an MP3 player!\n";
cin.get();
}
else if ( input == 'c' )
{
cout<<"The work paid off! You've won a Sony CD player!\n";
cin.get();
}
else if ( input == 'd' )
{
cout<<"This'll help you boost your score! Your very own National Book Club Subscription!\n";
cin.get();
}
else if ( input == 'e' )
{
cout<<"Here is some candy, maybe it will boost your brain power!\n";
cin.ignore();
}
else if ( input != 'b' || input != 'c' || input != 'd' || input != 'e' )
{
cout<<"Error. Please enter a, b, c, d, or e\n";
cin.get();
}
cin.get();
}
else if ( books >= 50 )
{
cout<<"Listed below are your options:\n";
cout<<" c : Sony Cd Player!\n";
cout<<" d : Book Subscription!\n";
cout<<" e : A peice of Candy!\n";
cin>> input;
cin.ignore();
if ( input == 'c' )
{
cout<<"The work paid off! You've won a Sony CD player!\n";
cin.get();
}
else if ( input == 'd' )
{
cout<<"This'll help you boost your score! Your very own National Book Club Subscription!\n";
cin.get();
}
else if ( input == 'e' )
{
cout<<"Here is some candy, maybe it will boost your brain power!\n";
cin.ignore();
}
else if ( input != 'c' || input != 'd' || input != 'e' )
{
cout<<"Error. Please enter a, b, c, d, or e\n";
cin.get();
}
cin.get();
}
else if ( books >= 25 )
{
cout<<"Listed below are your options:\n";
cout<<" d : Book Subscription!\n";
cout<<" e : A peice of Candy!\n";
cin>> input;
cin.ignore();
if ( input == 'd' )
{
cout<<"This'll help you boost your score! Your very own National Book Club Subscription!\n";
cin.ignore();
}
else if ( input == 'e' )
{
cout<<"Here is some candy, maybe it will boost your brain power!\n";
cin.ignore();
}
else if ( input != 'd' || input != 'e' )
{
cout<<"Error. Please enter a, b, c, d, or e\n";
cin.get();
}
cin.get();
}
else if ( books >= 1 )
{
cout<<"Listed below are your options:\n";
cout<<" e : A peice of Candy!\n";
cin>> input;
if ( input == 'e' )
{
cout<<"Here is some candy, maybe it will boost your brain power!\n";
cin.get();
}
}
else if ( books == 0 )
{
cout<<"Listed below are your options:\n";
cout<<"Sorry, Start reading and maybe you'll win something next time!\n";
}
else if ( books != 0 && books != 1-320000 || books < 0 )
{
cout<<"Error. Please enter a positive integer.\n";
cin.get();
}
cout<<"Input any key to continue, type quit to close out.\n";
cin>> i;
cin.ignore ();
cin.get();
return 0;
}
}
Ok, let me know where my logic is wrong, thanks