Code:
#include <iostream>
using namespace std;
int main()
{
int select; //the actual selection you'll be inputing
int selectCount = 0; //you'll see why i made this later. make sure it's initialized
while (selectCount < 1) //while the variable selectCount is zero
{
cout<<"Choice: "; //displays choice
cin>>select; //input number for the variable select
cin.ignore() //doesnt close the program when enter is pushed
if (select == 1) //if you type in 1 for the select variable
{
cout<<"\nBla, bla, I pick one!\n"; //what is displayed when 1 is assigned to select
selectCount++; //adds 1 to selectCount, making it 1 and ending the while loop
}
else if (select == 2) //if you type in 2 for the select variable
{
cout<<"\nBla, bla, I pick two!\n"; //what is displayed when 2 is assigned to select
selectCount++; //adds 1 to selectCount, making it 1 and ending the while loop
}
else //if anything else is input
{
cout<<"\nInvalid Choice!\n\n"; //what is displayed when anything besides 1 or 2 is input
} //notice there is no selectCount++; , because we dont want the loop to end until 1 or 2 is input
}
cin.get(); //push enter before program closes
return 0; //and voila!
}
I hope that helps.