import java.util.Scanner;
public class If01 {
public static void main(String[] args) {
System.out.println("请输入一个月份:");
Scanner input = new Scanner(System.in);
int month = input.nextInt();
String str = "";
if (month>=3 && month<=5){
str = "春季";
}else if (month>=6 && month<=8){
str = "夏季";
}else if (month>=9 && month<=11){
str = "秋季";
}else if (month>=12 || (month>=1 && month<=2)){
str = "冬季";
}else {
str = "输入不合法";
}
System.out.println("对应的季节为:" + str);
}
}
import java.util.Scanner;
public class If02 {
public static void main(String[] args) {
int ran = (int)(Math.random()*90+10);
int numShiWei = ran/10;
int numGeWei = ran%10;
Scanner input = new Scanner(System.in);
System.out.println("请输入两位数字");
int shu = input.nextInt();
int shuShiWei = shu/10;
int shuGeWei = shu%10;
if(ran == shu){
System.out.println("奖金10000美元");
}else if(numShiWei == shuGeWei && numGeWei == shuShiWei){
System.out.println("奖金3000");
}else if(numShiWei == shuShiWei || numGeWei == shuGeWei){
System.out.println("奖金1000");
}else if(numShiWei == shuGeWei || numGeWei == shuShiWei){
System.out.println("奖金500");
}else{
System.out.println("没中奖");
}
System.out.println("中奖数字是:" + ran );
System.out.println("您的数字是:" + shu );
}
}
import java.util.Scanner;
public class If03 {
public static void main(String[] args) {
System.out.println("请输入狗的年龄:");
Scanner input = new Scanner(System.in);
int dogAge= input.nextInt();
if(dogAge>0 && dogAge<=2){
System.out.println("相当于人的年龄:" + dogAge * 10.5);
}else if(dogAge>2){
System.out.println("相当于人的年龄:" + (2* 10.5+(dogAge-2)*4));
}else{
System.out.println("狗狗还没出生");
}
}
}