There’s a number of issue in your code.
Some of them:
1) Declare your variables only when you need them.
Declaring a variable when you don’t have a good value to initialize it at, makes your code harder to read and introduces subtle bugs.
Declaring all the variables in a bunch at the beginning of functions is a bad habit.
2) Do not use “using namespace std;”.
Another bad habit. Leave it to the experts.
3) Make “letter” local.
4) You don’t need “keepOn”.
Your loop condition is “ std::cin.get( letter ) && '\n' != letter ”.
5) “firstTime” is supposed to be used before giving the answer, i.e. after the loop - anyway, outside it.
6) In the ANSI table there’s a bunch of unwanted characters between the 'Z' and the 'a'.
You need to improve a lot your ‘if’ condition to ensure you’re dealing only with the the English alphabet.
You could consider std::library functions like std::isspace(), std::isalnum() and so on.
More details here:
http://www.cplusplus.com/reference/cctype/
https://en.cppreference.com/w/cpp/header/cctype
Otherwise I think the logic should be:
if letter is less than 'A'
or 'z' is less than letter
or ( 'Z' is less than letter
and letter is less than 'a' ) |
7) do use the tags [ code] [/ code] to get better answers.
EDIT
What’s bad in lastchance’s code here?
http://www.cplusplus.com/forum/beginner/268907/