ADD file via upload

master
pj3q7x5mz 2 years ago
parent 71393b2dce
commit ee50af9f80

@ -0,0 +1,101 @@
1.Java分支结构之多重if
package step3;
import java.util.Scanner;
public class HelloStep3 {
public static void main(String[] args) {
System.out.println("星级成绩评定系统");
System.out.println("请输入成绩:");
Scanner sc = new Scanner(System.in);
/******start******/
int score;
score=sc.nextInt();
if(score>=90&&score<=100)
{
System.out.print("*****五星成绩");
}
else if(score<90&&score>=80)
{
System.out.print("****四星成绩");
}
else if(score<80&&score>=70)
{
System.out.print("***三星成绩");
}
else if(score<70&&score>=60)
{
System.out.print("**俩星成绩");
}
else if(score<60)
{
System.out.print("无星成绩");
}
/******end******/
}
}
2.Java分支结构之Switch
package step4;
import java.util.Scanner;
public class HelloSwitch {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入月份:");
int input = sc.nextInt(); //获取输入的月份
//通过输入的月份来判断当前季节并输出
/*****start*****/
int season;
switch(input)
{
case 1:
System.out.print("1月是冬天");
break;
case 2:
System.out.print("2月是冬天");
break;
case 3:
System.out.print("3月是春天");
break;
case 4:
System.out.print("4月是春天");break;
case 5:
System.out.print("5月是春天");
break;
case 6:
System.out.print("6月是夏天");
break;
case 7:
System.out.print("7月是夏天");
break;
case 8:
System.out.print("8月是夏天");
break;
case 9:
System.out.print("9月是秋天");
break;
case 10:
System.out.print("10月是秋天");
break;
case 11:
System.out.print("11月是秋天");
break;
case 12:
System.out.print("12月是冬天");
break;
}
/*****end*****/
}
}
Loading…
Cancel
Save