Answer to Question #288842 in Java | JSP | JSF for Adeng

Question #288842

Write a program that accepts a number from 1 to 365 and determine equivalent date. You may use any Control Statement.


Example Output of the Program:


Input a number from 1 to 365: 1

Your number’s equivalent in date is: January 1


1
Expert's answer
2022-01-19T10:35:32-0500
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());
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog