Write a program that accepts a number from 1 to 365 and determine equivalent date. You may use any
Control Statement.
import java.time.LocalDate;
import java.time.format.TextStyle;
import java.util.Locale;
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Input a number from 1 to 365: ");
LocalDate date = LocalDate.now().withDayOfYear(scanner.nextInt());
System.out.print("Your number’s equivalent in date is: ");
System.out.printf("%s %d%n", date.getMonth().getDisplayName(TextStyle.FULL, Locale.ENGLISH), date.getDayOfMonth());
}
}
Comments
Leave a comment