Created
August 26, 2020 10:08
-
-
Save SiAust/2ae19121f5db9ee674911d2c094f0efd to your computer and use it in GitHub Desktop.
Output each Monday of a given month.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.time.DayOfWeek; | |
| import java.time.LocalDate; | |
| import java.util.Arrays; | |
| import java.util.Scanner; | |
| class Main { | |
| public static void main(String[] args) { | |
| Scanner sc = new Scanner(System.in); | |
| int[] input = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray(); | |
| LocalDate date = LocalDate.of(input[0], input[1], 1); | |
| for (int i = 0; i < date.lengthOfMonth(); i++) { | |
| if (date.plusDays(i).getDayOfWeek() == DayOfWeek.MONDAY) { | |
| System.out.println(date.plusDays(i)); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment