import java.util.Scanner;public class IfElseSwitch {public static void main(String[] args) {// if 单循环结构//创建扫描器,进行键盘录入Scanner scanner = new Scanner(System.in);String str = Line();if(str.equals("Hello")){System.out.println(str);}System.out.println("结束");//scanner.close();// if 双选择结构Scanner scanner1 = new Scanner(System.in);System.out.println("请输入成绩:");int score = Int();if( score > 60 ){System.out.println("及格!");} else {System.out.println("不及格!");}//scanner1.close();// if 多重选择/*一旦一个else if{}中的条件满足,则跳出多重循环*/Scanner scanner2 = new Scanner(System.in);System.out.println("请输入成绩:");int score1 = Int();if(score1==100){System.out.println("满分!");} else if ( score1 >= 80 && score1 < 90 ){System.out.println("A");} else if ( score1 >= 70 && score1 < 80 ){System.out.println("B");}else if ( score1 >= 60 && score1 < 70 ){System.out.println("C");}else if ( score1 >= 0 && score1 < 60 ) {System.out.println("不及格!");}else {System.out.println("输入的成绩不符合规范!");}scanner2.close();}
}
本文发布于:2024-01-28 05:28:39,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/17063909235126.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |