Your code will put invalid every time the entered parking level is not 'C' or 'c'. This is because the else-part of this statement only belongs to the last if, which checks if the parking level is 'C' or 'c'. You could make it belong to all statements by changing your if conditionals into else if (which would also exclude some unnecessary tests):