Question
CODING IN JAVA Dates are printed in several common formats. Two of the more common formats are: 07/21/55 and July 21, 1955 Write a program
CODING IN JAVA
Dates are printed in several common formats. Two of the more common formats are:
07/21/55 and July 21, 1955 Write a program that reads a date in the first format and prints that date in the second format. Prompt the user and accept user input for the date in MM/DD/YYYY format. Retrieve the month portion of the date entered and convert it to an integer. Do the same thing for day and year Create a string named months that contains the number of the month and the name of the month: 1 January2 February3 March. Convert the month into a string Find the index where the numeric value for the month is held Retrieve the text version of the month. Output the date in expanded format. //Sample run #1 Enter a date in MM/DD/YYYY format: 04/12/2000 April 12, 2000
//Sample run #2 Enter a date in MM/DD/YYYY format: 11/10/2000 November 10, 2000
//Sample run #3 Enter a date in MM/DD/YYYY format: 12/20/2000 December 20, 2000
Note that for sample run 3, you are likely to get an out of bounds error unless you provide a 13th option within the string. Exception in thread "main" java.lang.StringIndexOutOfBoundsException: begin 90, end -1, length 98 at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3107) at java.base/java.lang.String.substring(String.java:1873) at edu.ilstu.DateProgram.main(DateProgram.java:20)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started