Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```java
- ublic static int numberOfLeapYears(int year1, int year2) {
- int counter = 0;
- for (int i = year1; i <= year2; i++)
- if (isLeapYear(i))
- counter++;
- return counter;
- }
- public static int dayOfWeek(int month, int day, int year) {
- return (dayOfYear(month, day, year) + firstDayOfYear(year) - 1) % 7;
- }
- public class StepTracker {
- private int activeThreshold;
- private int totalSteps;
- private int days;
- private int activeDays;
- public StepTracker(int activeThreshold) {
- this.activeThreshold = activeThreshold;
- totalSteps = 0;
- days = 0;
- activeDays = 0;
- }
- public void addDailySteps(int steps) {
- days++;
- totalSteps += steps;
- if (steps >= activeThreshold)
- activeDays++;
- }
- public int activeDays() {
- return activeDays;
- }
- public double averageSteps() {
- return (double) totalSteps / days;
- }
- }
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement