Advertisement
Guest User

Untitled

a guest
Oct 6th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. public class LeapYear{
  2.  
  3.    private int year;
  4.    private boolean isLeapYear;
  5.  
  6.    public LeapYear(int y) {
  7.        year = y;
  8.    }
  9.  
  10.    // write this
  11.    // Sets isLeapYear to true if year is divisible by 4, unless it is
  12.    // also divisible by 100 and not divisible by 400.
  13.    // Otherwise isLeapYear is set to false.
  14.    public void setLeapYear() {
  15.       if (year % 4 == 0) {
  16.         isLeapYear = true;
  17.         if (year % 100 == 0 && year % 400 != 0) {
  18.             isLeapYear = false;
  19.         }
  20.       } else {
  21.         isLeapYear = false;    
  22.       }
  23.      
  24.      
  25.      
  26.      
  27.      
  28.      
  29.      
  30.      
  31.    }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement