//R. A. Hillyard
//cinTest.cpp
//program to demonstrate how to recover from
//input errors using the cin member functions
//
//step one - illustrate the problem
//the below code will work fine as long as we enter an
//integer - if we enter a char or decimal number, the
//program will not work as expected
#include<iostream>
#include<cctype> //for toupper
using namespace std;
int main()
{
char charChoice; //hold character entered by user
int intChoice; //hold int entered by user
do
{
cout << "\n*** Welcome to some program ***\n\n";
cout << "Enter an integer : ";
cin >> intChoice;
cout << "You entered a: " << intChoice << endl;
cout << "\nTry again?? [Y/N]: ";
cin >> charChoice;
charChoice = toupper(charChoice);
}while(charChoice != 'N');
}//end main
//run the program with the following data and note the results
//test1 - enter 5 (valid integer)
//test2 - enter c (char - invalid integer - causes a loop)
//test3 - enter 55.66 (what happened???)