Computer Programming I :: Projects :: Leap Years
Leap years are necessary because the earth revolves around the sun once every 365.242199 days. Without adding a day to the calendar every four years we would end up losing nearly six hours a year, which can add up to losing a day after just four years. A leap year must satisfy these conditions:
- The year must be divisible by 4
- The year must NOT be divisible by 100 unless...
- The year is divisible by 400
For this project the user will enter two years. The program will determine how many leap years are in between the two given years. You should also write out the steps of your algorithm before beginning your program.
- Write the steps of your algorithm and turn them in along with your finished program.
- Use text boxes for the start and end years.
- Integer variables should be used to store the text box contents.
- A while loop should be used to run through the range of years.
- Modulus should be used to determine the divisiblity of the years.
- A MessageBox should display the number of leap years between the two given years when the user hits a button.
- Determine a good name for each variable following the rules.
- Rename the form and all controls on the form using a three-letter prefix.
- Add a comment header following class guidelines.
Get the program to work using only one if statement.
- Use the example to determine if your results are correct.
- One number is divisible by another number if oneNum % anotherNum == 0.