Your first approach as you may have figured out by yourself had a static casting to itself (
scoreB
is double and a casting to double does not change it a bit).
You just want to see if scoreB is int right?
Well if you define scoreB as int cin would take just the integral part of your real number that is if you enter
1.2, scoreB would be 1. I am not sure you want this but you can have it mind. No validating user input here needed (at least if user inputs a number and not a alphanumeric).
Also another point is that if you define a variable as int you can get integral part of scoreB by using:
int score = scoreB;
. No big gain here since the last approach of course.
Also if your compiler gives you an error (meaning you cannot compile the program) for this casting you can either change the level of error detection of your compiler or just use another int variable where you can store scoreB integral part and then compare.
As for the case where user enters alphanumeric I don't know why it goes to infinite loop but you can overcome this if you handle your input as string. Some extra steps are required here in this case but you are covered for all cases.
If you are interested in this see
http://www.cplusplus.com/forum/beginner/57855/