本帖最后由 吉吉粥 于 2015-12-6 17:56 编辑
- import java.util.Scanner;
- class Demo2 {
- public static void main(String[] args){
-
- Scanner sc = new Scanner(System.in); //创建键盘输入对象, 封装键盘录入
-
- System.out.println("请输入您的分数:");
- int x = sc.nextInt();
- if(x >= 90 & x <= 100) {
- System.out.println(x + "优");
- }else if(x >= 80 & x <= 89) { //关系运算符,书写按照读法书写 大于等于 小于等于 "="在最后打
- System.out.println(x + "良");
- }else if(x >= 70 & x <= 79) {
- System.out.println(x + "中");
- }else if(x >= 60 & x <= 69) {
- System.out.println(x + "及");
- }else if(x >= 0 & x <= 59) {
- System.out.println(x + "差");
- }else {
- System.out.println("输入分数有误");
- }
- }
- }
复制代码
|
|