Monday, March 7, 2011

Post 4

Done with if...else statement ? Lets switch to the new statement of selection that are switch statement. Switch statement is very useful to replace nested if statement. For example, if we want to make a program to determine the performance of the student based on their current class.

Click here for coding.

This program will display whether the students is a genius, good, average or poor students based on their current class. The default statement is like else statement. It will be executed if the user didn't enter A, B, C or D class.

Post 3

This is an extended post for selection. The first example is the one we always use in our daily lives, that is to calculate the BMI of a person.

Click here for coding.

It will display your current BMI based on your weight and height that you have entered and it also tell you whether you're underweight, normal weight or overweight.

The next example will show you how to use Boolean expressions along with selection statement.
This program is to determine whether the year that user input is a leap year or not.

Click here for coding.