Challenge: Days Until

Lab Java Beginner 10 points

Read two dates in the form yyyy-mm-dd (one per line). Print the number of days from the first to the second, and the day of the week of the second date.

Input

Two lines, each a date like 2026-10-18. The second date is not before the first.

Output

Days: <n>
That is a <DAY OF WEEK>

Example

Input

2026-10-18
2027-01-01

Output

Days: 75
That is a FRIDAY
Sample input available Sample output available
Editor
Java

Hints

LocalDate.parse("2026-10-18") understands this format directly.

ChronoUnit.DAYS.between(a, b)

Solution explanation

java.time knows about leap years, so 2024-02-28 to 2024-03-01 is correctly 2 days.

Show solution
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        LocalDate a = LocalDate.parse(sc.nextLine().trim());
        LocalDate b = LocalDate.parse(sc.nextLine().trim());
        System.out.println("Days: " + ChronoUnit.DAYS.between(a, b));
        System.out.println("That is a " + b.getDayOfWeek());
    }
}
Output
Answer
HOME LABS COMMUNITY DASHBOARD