黑马程序员技术交流社区
标题:
今天学的代码,根据输入月份输出季节
[打印本页]
作者:
sq_jun
时间:
2015-1-20 22:16
标题:
今天学的代码,根据输入月份输出季节
/**
*
* @author 张耀军
*/
import java.util.Scanner;
class abc
{
public static void main(String[] args)
{
int i=1;
i*=2;
String season[]={"春","夏","秋","冬"};
String str="";
try{
Scanner sc=new Scanner(System.in);
System.out.println("请输入月份:");
int month=sc.nextInt();
if(month==1||month==2||month==12)
str=season[3];
else if(month==3||month==4||month==5)
str=season[0];
else if(month==6||month==7||month==8)
str=season[1];
else if(month==9||month==10||month==11)
str=season[2];
else
str="输入有误";
System.out.println(str);
}catch(Exception e){
e.printStackTrace();
}
}
}
复制代码
作者:
梦开始的地方
时间:
2015-1-21 16:03
请问,你也是java刚开始学基础吗?
作者:
qq306149769
时间:
2015-1-21 21:45
加油!如果在基础班,进度也挺快的,有时间尽量自己往下看视频!
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2