How to set the if condition to make the calculator work?