If I understand your question correctly then you already have a class declaration, the static arrays defined, and a main method written, and it looks something like this (
warning this could be a portion of the answer):
public class DateHomework {
static String [] monthsArray = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
static int [] daysinMothArray = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
static String [] daysinMonthArray = {"st", "nd", "rd", "th"};
public static void main(String[] args){
System.out.println(date(11, 4, 2003));
System.out.println(date(30, 6, 2009));
}
//plus more...
}
you also have a method declaration for your date method and it looks something like this (
warning this could be a portion of the answer):
public static String date(int day, int month, int year){
//that date method...
}
you just need help understanding how to convert the integer representation of the date to the word representation, given that your teacher wants you to use those arrays defined earlier.
If that's the case then here is a big hint on how to do that (
warning this could be a HUGE portion of the answer):
public class DateHomework {
static String [] monthsArray = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
static int [] daysinMothArray = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
static String [] daysinMonthArray = {"st", "nd", "rd", "th"};
public static void main(String[] args){
System.out.println(date(11, 4, 2003));
System.out.println(date(30, 6, 2009));
}
public static String date(int day, int month, int year){
//create the string that the method will return
String result;
//make sure the month argument is valid
if ((month <= 12)&&(month > 0)){
//the first element in an array is element zero, but the first month of the year is month number one.
result = monthsArray[month - 1];
}else{
result = "invalid month";
}
//make sure the day argument is valid
if ((day <= daysinMothArray[month -1])&&(day > 0)){
result = result + " " + day;
//add the right day ending
if(((day > 3)&&(day < 21))||((day > 23)&&(day<31))){ //if it should end in "th"
result = result + daysinMonthArray[3];
}
//add code for the "st", "nd", and "rd" endings...
}else{
result = result + " invalid day";
}
//make sure the year argument is valid
if (year >= 1){
result = result + " " + year;
}else{
result = result + " invalid year";
}
return result;
}
}
On my machine the above code was able to compile and produce the correct results. However, I made many assumption, and this might not be the code you're looking for. Regardless I hope it helps