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

This has to be done in Java, I did something like making string variables for mm

ID: 3620364 • Letter: T

Question

This has to be done in Java, I did something like making string variables for mm, dd and yy but had no luck. I don't have my file with me right now so I won't be able to post it until I get home. It should not use the calendar library. The output should be like this:

Enter Date (mm/dd/yy): 02/08/91

The date is: February 8th 91.

Please help me out! or give me suggestions on how to do this.

Here is my work:

import javax.swing.JOptionPane;


public class Assignment2{

public static void main(String[] args){

String choice = "";

while (!(choice.equalsIgnoreCase("x"))){

String inputDate = JOptionPane.showInputDialog("Enter Date: ");
String day = inputDate.substring(3,5);
String month = inputDate.substring(0,2);
String year = inputDate.substring(6,8);

int d= Integer.parseInt(day);
int m= Integer.parseInt(month);
int y=Integer.parseInt(year);
String months [] = {"jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"};

String message = "Input date: " + inputDate + " is:" + " "
+ day + " " + month + " " + year + "Press Enter to continue or enter 'x' to exit.";

choice = JOptionPane.showInputDialog(null, message, "Get Date Input", JOptionPane.PLAIN_MESSAGE);


} // end while

System.exit(0);
}
}

I am really stuck!! please help me

Explanation / Answer

I think what you might want to do is use a switch statement for you days and months and use concat to put them all together in a single string to print out. There's a couple different ways to do it. This site explains switch statements and it directly applies to your task.
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