16.ifelse句自由拓展
import java.util.*;//声明Scanner
public class Main {//类型
public static void main(String[]args){//入口
Scanner input = new Scanner(System.in);
System.out.println("请输入a值");
int custNo=input.nextInt();
if (custNo>1000&&custNo<2000){
System.out.print("大于1K");
}else if(custNo>2000&&custNo<3000){
System.out.println("大于2K");
}else if (custNo>3000){
System.out.print("大于3K");
}else{
System.out.print("一千以下的正整数");
}
}
}
自由拓展
import java.util.*;//声明Scanner
public class Main {//类型
public static void main(String[]args){//入口
Scanner input = new Scanner(System.in);
System.out.println("请输入成绩");
int custNo=input.nextInt();
if (custNo>=90){
System.out.print("大于90,优秀");
}else if(custNo>=80){
System.out.println("大于80,良好");
}else if (custNo>=60){
System.out.print("大于60,中等");
}else{
System.out.print("小于60,差劲");
}
}
}