SHARE
TWEET

Untitled

a guest May 19th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ```java
  2. ublic static int numberOfLeapYears(int year1, int year2) {
  3.       int counter = 0;
  4.       for (int i = year1; i <= year2; i++)
  5.          if (isLeapYear(i))
  6.             counter++;
  7.       return counter;
  8.    }
  9.    public static int dayOfWeek(int month, int day, int year) {
  10.       return (dayOfYear(month, day, year) + firstDayOfYear(year) - 1) % 7;  
  11.    }
  12. public class StepTracker {
  13.    private int activeThreshold;
  14.    private int totalSteps;
  15.    private int days;
  16.    private int activeDays;
  17.    
  18.    public StepTracker(int activeThreshold) {
  19.       this.activeThreshold = activeThreshold;
  20.       totalSteps = 0;
  21.       days = 0;
  22.       activeDays = 0;
  23.    }
  24.    public void addDailySteps(int steps) {
  25.       days++;
  26.       totalSteps += steps;
  27.       if (steps >= activeThreshold)
  28.          activeDays++;
  29.    }
  30.    public int activeDays() {
  31.       return activeDays;
  32.    }
  33.    public double averageSteps() {
  34.       return (double) totalSteps / days;
  35.    }
  36. }
  37. ```
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top