Hello I'm new in using java i just need some advice..
this is what i need to do: the user inputted the date 8/15/2018, the console should have the output: "Hello! This is day 15 of the month of August in the year of our Lord 2018."
this is my code
package newdate;
import java.util.Scanner;
public class NewDate {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the date in mm/dd/yyyy: ");
String str=sc.next();
switch (str) {
case 1: str.substring(0,2) = "January";
break;
case 2: str.substring(0,2) = "February";
break;
case 3: str.substring(0,2) = "March";
break;
case 4: str.substring(0,2) = "April";
break;
case 5: str.substring(0,2) = "May";
break;
case 6: str.substring(0,2) = "June";
break;
case 7: str.substring(0,2) = "July";
break;
case 8: str.substring(0,2) = "August";
break;
case 9: str.substring(0,2) = "September";
break;
case 10: str.substring(0,2) = "October";
break;
case 11: str.substring(0,2) = "November";
break;
case 12: str.substring(0,2) = "December";
break;
default: str.substring(0,2) = "Invalid month";
break;
}
System.out.println("Hello! This is day " + str.substring(3,5) +" of the month of " + str.substring(0,2) +" in the year of our Lord" + str.substring(6,10));
}
}
the problem is the data type, i want the month which is a number will be replace by a string(month) example: 11 = November
how can i do it?