Combine the operators. See Equality, Relational, and Conditional Operators . If you get stuck along the way I'd recommend posting code with a defined question to get a quicker and more precise...