| Chapter 3- Data Types and Operators | Boolean Expressions Page 2 3 4 |
| The If Statement Page 2 3 4 5 6 7 8 9 | |
| Arithmetic Operations Page 2 3 4 5 6 | Boolean Operators and Nested If Statements Page 2 3 4 5 6 7 |
| Events and Sequential Processing Page 2 3 4 5 | More Examples Page 2 3 4 5 6 7 8 9 10 11 12 |
| Datatypes and Conversions Page 2 3 4 5 6 7 | Using Check Box and Option Controls Page 2 3 4 5 6 7 8 9 10 |
| Variable Declarations - Local and Global Page 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | Exercises Page 2 3 4 5 6 7 8 |
| Chapter 4- Selection Statements | Review Questions |
| Introduction | |
4-6: More on Nested If Statements
Exercise 4-5: Zeller's Algorithm (continued)
The month value obtained from the function will have a value from 1 to 12 for January to December and must therefore be changed so that 1 and 2 (Jan. and Feb.) become 11 and 12 and the rest (Mar. to Dec.) become 1 to 10. One way to implement this is:
If (mValue > 2) then
m = mValue
- 2
Else
m = mValue + 10
End
If
where m is a new variable that must be declared as Integer type and will be used in the Zeller expression.
The year value must be changed if the month is January or February by subtracting 1. Another If statement will do this. Use yValue as the variable name.
Next the century and the year in the century must be obtained (i.e. if the year is 1876 we need 18 for the century and 76 for the year in the century). To calculate these values you need to consider what happens when you divide the year by 100. Use variables names c and y.