do
{
cout << "and how many of the 4 opponents would you like to play aganst?"<<endl;
cin >> numberofopponents;//were the user inputs the number of opponents
if(numberofopponents==1)//the if statment that plays the game if the user choses 1 opponents
{
cout<<"1 opponent......really????? ... noob"<<endl;
cout << "round one!"<<endl;
cout << setw(15) << "Place" << setw(15) << "Name" << setw(15) << "Dollars" <<endl;
cout << setw(15) << "1st" << setw(15) << name1 << setw(15) << "100" <<endl;
cout << setw(15) << "1st" << setw(15) << "Jenneifer" << setw(15) << "250" <<endl;
cout<<setw(15)<<"1st"<<setw(15)<<"The House "<<setw(15)<<" so much that god owes us"<<endl;
}
else if(numberofopponents==3)//the if statment that plays the game if the user choses 3 opponents
{
cout<<"3 opponents? daring move old chum daring move indeed"<<endl;
cout <<"round one!"<<endl;
cout << setw(15) << "Place" << setw(15) << "Name" << setw(15) << "Dollars" <<endl;
cout << setw(15) << "1st" << setw(15) << name1 << setw(15) << "100" <<endl;
cout << setw(15) << "1st" << setw(15) << "Joshua" << setw(15) << "250" <<endl;
cout << setw(15) << "1st" << setw(15) << "Simon" << setw(15) << "250" <<endl;
cout << setw(15) << "1st" << setw(15) << "Chang" << setw(15) << "250" <<endl;
cout<<setw(15)<<"1st"<<setw(15)<<"The House "<<setw(15)<<" censored for your protection"<<endl;
}
else if(numberofopponents==2)//the if statment that plays the game if the user choses 2 opponents
{
cout<<"2 opponents it is!"<<endl;
cout <<"round one!"<<endl;
cout << setw(15) << "Place" << setw(15) << "Name" << setw(15) << "Dollars" <<endl;
cout << setw(15) << "1st" << setw(15) << name1 << setw(15) << "100" <<endl;
cout << setw(15) << "1st" << setw(15) << "Timmy" << setw(15) << "250" <<endl;
cout << setw(15) << "1st" << setw(15) << "Greg Ramsay" << setw(15) << "250" <<endl;
cout<<setw(15)<<"1st"<<setw(15)<<"The House "<<setw(15)<<" so much god owes us"<<endl;
}
else if(numberofopponents==4)//the if statment that plays the game if the user choses 4 opponents
{
cout <<"4 opponents you say? how quaint somehow"<<endl;
cout <<"round one!"<<endl;
cout << setw(15) << "Place" << setw(15) << "Name" << setw(15) << "Dollars" <<endl;
cout << setw(15) << "1st" << setw(15) << name1 << setw(15) << "100" <<endl;
cout << setw(15) << "1st" << setw(15) << "Comp1" << setw(15) << "250" <<endl;
cout << setw(15) << "1st" << setw(15) << "Comp2" << setw(15) << "250" <<endl;
cout << setw(15) << "1st" << setw(15) << "Comp3" << setw(15) << "250" <<endl;
cout << setw(15) << "1st" << setw(15) << "Comp4" << setw(15) << "250" <<endl;
cout<<setw(15)<<"1st"<<setw(15)<<"The House "<<setw(15)<<" don't ask"<<endl;
}
else
cout <<" does not freakin compute"<<endl;
} while (numberofopponents<=0 || numberofopponents > 4);
}
i have made a program of blackjack and this piece has been bothersome to me for a while.
every time i try to input a letter into the numberofopponents it gives me the else statement in an infitie loop.
i have heard that i need to "fulsh the input"
please help me!