
Please help me with this Write a program that prompts and accepts a number between 1 and 12. After getting the input, display the number with the appropriate month. (example: This is the 1st month¦January, This is the 2nd month¦February, This is the 12th month¦December).
Thanks

import java.text.*;
import java.util.*;
class PrintMonth
{
public static String getMonthForInt(int m) {
String month = "invalid";
DateFormatSymbols dfs = new DateFormatSymbols();
String[] months = dfs.getMonths();
if (m >= 0 && m <= 11 ) {
month = months[m];
}
return month;
}
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.print("Enter number between 1 and 12: ");
int num=input.nextInt()-1;
System.out.println("Month is: "+getMonthForInt(num));
}
}

//please reply if my post really helps
import java.io.*;
class Month
{
public static void main()throws IOException
{
BufferedReader in= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter number between 1 and 12: ");
int num=Integer.parseInt(in.readLine());
String mn[]={January,February,March,April,May,June,July,August,September,Octobr,November,December};
if(num==1)
System.out.println(num+"st month "+mn[num-1];
else if(num==2)
System.out.println(num+"nd month "+mn[num-1];
else if(i==3)
System.out.println(num+"rd month "+mn[num-1];
else
System.out.println(num+"th month "+mn[num-1];
}
}

//copy the previous code in notepad and run in bluej
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.