求助简单的JAVA编程题
编写一个程序,声明一个数组来存放12个月的英文名称,由用户输入1-12的任意整数,输出相应月份!?...
编写一个程序,声明一个数组来存放12个月的英文名称,由用户输入1-12的任意整数,输出相应月份!?
展开
展开全部
import java.io.*;
class test
{
public static void main(String []args)
{
String []a={"January","February","March","April","May","June","July","August","September","October","November","December",};
int i;
System.out.println("请输入月份:");
i=MyInput.readInt();
System.out.println(a[i]);
}
}
class MyInput
{
public static String readString()
{
BufferedReader br
=new BufferedReader(new InputStreamReader(System.in),1);
String string=" ";
try
{
string=br.readLine();
}
catch (IOException ex)
{
System.out.println(ex);
}
return string;
}
public static int readInt()
{
return Integer.parseInt(readString());
}
public static double readDouble()
{
return Double.parseDouble(readString());
}
}
class test
{
public static void main(String []args)
{
String []a={"January","February","March","April","May","June","July","August","September","October","November","December",};
int i;
System.out.println("请输入月份:");
i=MyInput.readInt();
System.out.println(a[i]);
}
}
class MyInput
{
public static String readString()
{
BufferedReader br
=new BufferedReader(new InputStreamReader(System.in),1);
String string=" ";
try
{
string=br.readLine();
}
catch (IOException ex)
{
System.out.println(ex);
}
return string;
}
public static int readInt()
{
return Integer.parseInt(readString());
}
public static double readDouble()
{
return Double.parseDouble(readString());
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询