Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that prompts the user for a data in dd/mm/yyyy format (e.g., \"0

ID: 3820356 • Letter: W

Question

Write a program that prompts the user for a data in dd/mm/yyyy format (e.g., "04/13/2010"); the program will then write out the equivalent date in "month dd yyyy" format (April 13 2017). You must store the date that the user might enter in an array of char. You can store the individual parts of compound words in separate arrays, for example, store "04", "13" and "2010" in separate arrays instead of a single array with "04/13/2010" in it. Sample Output: Here is some sample output (from multiple runs) to give you an idea of what you are trying to achieve. Enter a date in dd/mm/yyyy format: 05/02/2013 You entered May 02 2013 Enter a date in dd/mm/yyyy format: 12/10/2015 You entered December 10 2015 Enter a date in dd/mm/yyyy format: 01/30/2018 You entered January 30 2018

Explanation / Answer

Below is the java code for the given requirement

TestDate.java

import java.util.Scanner;

public class TestDate {
   public static void main(String[] args) {
       //to read the input value entered in the console
       Scanner scan = new Scanner(System.in);
      
       System.out.print("Enter a date in dd/mm/yyyy format: ");
       String givenDate = scan.nextLine();
       //set the day month and year into array
       String[] date = givenDate.split("/");

       System.out.println("You Entered: "+getMonth(date[1]) + " " +date[0] + " " + date[2]);
       scan.close();
   }

   public static String getMonth(String month) {
       String monthName="";
       switch (month) {
       case "01":
           monthName= "January";
           break;
       case "02":
           monthName= "Febrauary";
           break;
       case "03":
           monthName= "March";
           break;
       case "04":
           monthName= "April";
           break;
       case "05":
           monthName= "May";
           break;
       case "06":
           monthName= "June";
           break;
       case "07":
           monthName= "July";
           break;
       case "08":
           monthName= "August";
           break;
       case "09":
           monthName= "September";
           break;
       case "10":
           monthName= "October";
           break;
       case "11":
           monthName= "November";
           break;
       case "12":
           monthName= "December";
           break;
       default:
           System.out.println("Month should be between 01 to 12");
       }
       return monthName;
   }

}

Sample Output:

Enter a date in dd/mm/yyyy format: 02/04/1986
You Entered: April 02 1986

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote