Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class LeapYear{
- private int year;
- private boolean isLeapYear;
- public LeapYear(int y) {
- year = y;
- }
- // write this
- // Sets isLeapYear to true if year is divisible by 4, unless it is
- // also divisible by 100 and not divisible by 400.
- // Otherwise isLeapYear is set to false.
- public void setLeapYear() {
- if (year % 4 == 0) {
- isLeapYear = true;
- if (year % 100 == 0 && year % 400 != 0) {
- isLeapYear = false;
- }
- } else {
- isLeapYear = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement