class notes 06/13/06

Today's Menu

Assignment for chapter four is compute tax rate and overtime pay.

Send your quiz questions at ebrahimidr@gmail.com it should be true/false, non obvious, meaningful and useful.

To calculate the tax rate you need to have gross pay and rule (algorithm).

Leap year solution is on page 104 -105. Related to your assignment. We want to know whether is a leap year or not.
Questions:
How do you compute divisibility?
How do you know a number is odd or even?
Even: if you divide it by 2 and the remainder is 0
Odd: If divide by 2 and remainder is not 0
For this we use the mod function

How do you know x is even?
x - (x / 2 * 2 ) = 0 then, the number is even, otherwise x is odd.

This is what happens if you enter 5 for a year, you don't get an integer as a result.

 There is an integer function called int( ).    int( year/2 ). This function gives you an integer with no remainder.
Two ways to solve this problem.
* if int( year/ 4) * 4 = year , then msgbox("The Year is Leap Year?")
* if (year – (int(year /4)) * 4 = 0  then msgbox(“The Year is Leap Year?”)
Which one do you like?

Leap Year is any year that is divisible by 400 for sure is a leap year.

This is the output if you enter “2100” for year…