This checkpoint combines Day 1’s named values with today’s decisions and loops. Begin with a trace, not with code. List the days, the amount on each day and the running total. Then decide where initialization, updates and final reporting belong. You should not need methods or arrays yet.
The brief
A learner studies for 10, 20, 30 and 40 minutes on four consecutive days. Count days with at least 25 minutes, total all four days and report whether the total reaches a 90-minute goal. Use a loop to derive the amounts from day * 10. Do not write four separate additions or hard-code the final boolean answer.
Acceptance cases
With four days, expect total 100, long-day count 2 and goal reached true. With zero days, expect 0, 0 and false. With two days, expect 30, 0 and false. Changing the goal to exactly the total must still count as reached.
The worked examples use a different measurement. Explain what transfers and what does not: the accumulator pattern transfers, but the checkpoint’s rule about long days is a separate decision you must add yourself.
public class Main {
public static void main(String[] args) {
int distance = 0;
for (int trip = 1; trip <= 3; trip++) {
distance += trip * 2;
}
System.out.println(distance);
System.out.println(distance >= 12);
}
}Check your prediction
12
true The distance is 2+4+6. Comparison belongs after the accumulation when the question is about the whole plan. A comparison inside the loop asks about each partial total instead.
public class Main {
public static void main(String[] args) {
int matches = 0;
for (int value = 1; value <= 4; value++) {
if (value >= 3) {
matches++;
}
}
System.out.println(matches);
}
}Check your prediction
2 Counting does not require storing the selected values. In the checkpoint, compare the derived minute amount rather than comparing the day number directly to 25.
Your turn
Build the weekly report
Implement the four-day study plan. Print Total: 100, Long days: 2 and Goal reached: true. Keep day count and goal as starting variables so the acceptance cases can be checked by changing inputs.
public class Main {
public static void main(String[] args) {
int days = 4;
int goal = 90;
// Build and report the weekly totals.
}
}Hint 1: the idea
The total changes every day, but the long-day count changes only when its separate condition matches.
Hint 2: a first step
Initialize both accumulators before the loop. Inside it, derive the current duration before using it in either calculation.
Show one solution
public class Main {
public static void main(String[] args) {
int days = 4;
int goal = 90;
int total = 0;
int longDays = 0;
for (int day = 1; day <= days; day++) {
int minutes = day * 10;
total += minutes;
if (minutes >= 25) {
longDays++;
}
}
System.out.println("Total: " + total);
System.out.println("Long days: " + longDays);
System.out.println("Goal reached: " + (total >= goal));
}
}Total: 100
Long days: 2
Goal reached: true Change it and explain
Make a three-column trace: day, total and longDays. Find the first row where a mistaken implementation differs from yours. This is often faster than staring at the final number and guessing at a fix.
Close the solution and write the equivalent report for three reading sessions of 5, 10 and 15 pages, counting sessions of at least 10 pages. Explain the connection between the tasks without reusing the old answers. If you can transfer the pattern, you are ready to package useful operations as methods tomorrow.
Completion is saved in this browser only. It does not measure mastery.