// Program 60: Day Number to Date and Future Date import java.time.*; import java.time.format.DateTimeFormatter; import java.util.*; class DayNumberDate { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int dayNo = sc.nextInt(); int year = sc.nextInt(); int n = sc.nextInt(); boolean leap = Year.isLeap(year); if (year < 1000 || year > 9999 || dayNo < 1 || dayNo > (leap ? 366 : 365) || n < 1 || n > 100) { System.out.println("INVALID INPUT"); return; } LocalDate first = LocalDate.of(year, 1, 1).plusDays(dayNo - 1L); LocalDate future = first.plusDays(n); DateTimeFormatter fmt = DateTimeFormatter.ofPattern("d MMMM uuuu", Locale.ENGLISH); System.out.println(first.format(fmt).toUpperCase(Locale.ROOT)); System.out.println("DATE AFTER " + n + " DAYS: " + future.format(fmt).toUpperCase(Locale.ROOT)); } }