Copyright © 2005 Suradet Jitprapaikulsarn
สงวนลิขสิทธิ์ 2548 สุรเดช จิตประไพกุลศาล

Homework 11 (Due 5 September 2005)

1. Write a function, calcTax, to calculate the tax using the table

Year income

Rate

<= 100,000

0%

100,000 < income <= 500,000

12%

500,000< income <= 1,000,000

15%

1,000,000 < income <= 5,000,000

23%

> 5,000,000

28%

For instance, if the income is 3,500,000 then the tax = 500,000 x 12% +  500,000 x 15% + 2,500,000 x 23% = 710,000

2. Write the data definition of date to represent. (วัน เดือน ปี)

     - C definition / data example / code pattern

     - Scheme definition / data example / code pattern

  1. Write a function, isLeapyear, to check if a year is a leaps year. A leap year is a year which February has 29 days.
  2. Write a function, nDay, to calculate the number of days since new year.

        Hint:

             5%2   == 1         and     (mod 5 2)  = 1

             10%7 == 3         and     (mod 10 7) = 3

             21%4 == 1         and     (mod 21 4) = 1