Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.time.LocalDate;
- import java.time.format.DateTimeFormatter;
- import java.util.Date;
- import java.util.Scanner;
- public class P11_Date {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- String firstDate = scanner.nextLine();
- String secondDate = scanner.nextLine();
- DateTimeFormatter format = DateTimeFormatter.ofPattern("dd-MM-yyyy");
- int firstCount = 0;
- int secondCount = 0;
- for (int i = 1; i <= n; i++){
- if (i % 2 == 0){
- firstCount ++;
- } else {
- secondCount ++;
- }
- }
- LocalDate first = LocalDate.parse(firstDate, format).plusDays(firstCount);
- LocalDate second = LocalDate.parse(secondDate, format).plusDays(secondCount);
- int firstDays = first.getDayOfMonth();
- int secondDays = second.getDayOfMonth();
- System.out.println(firstDays + secondDays);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement