• 课堂复习内容(2)


                                                                               选择结构

    if:如果    else:否则    break:跳出     continue:持续     match:匹配

    gender:性别     random:随机数      score:成绩

    示例:1

       public class Demo{

          public static void main(String[]args){

           int  score=91;                     //可以把score写成输入;(详情在复习(1))

           if(score>=90){

             System.out.println("优");     // score>=90时;输出优

               }else{

             System.out.println("加油");  //score <90时;输出加油 

               }     

         }

         }

    示例:2

       嵌套结构:         

                          import java.util.*;
                             public class Test025 {
                             public static void main(String[] args) {
                               Scanner input = new Scanner(System.in);
                                 System.out.println("请输入成绩:");
                                      int score = input.nextInt();

                                       System.out.println("请输入性别:");
                                       char gender = input.next().charAt(0);

                                        if (score <= 10) {
                                           if (gender == '男') {
                                                System.out.println("进入男子决赛!");
                                                      } else if (gender == '女') {
                                                   System.out.println("进入女子决赛!");
                                                    }
                                                     } else {
                                                  System.out.println("淘汰!!");
                                               }
                                             }
                                        }

           

  • 相关阅读:
    .net core app的几个依赖究竟是什么
    ocelot identityserver4 consul整合漫谈
    错位重排算法公式的理解
    IIS证书配置。。这究竟是为什么
    .net core修改IIS发布的环境变量
    服务注册和发现组件-consul
    记一次失败的ubuntu虚拟机配置过程。。。
    .net core统一认证学习笔记(一)ocelot分析
    第四天
    第三天
  • 原文地址:https://www.cnblogs.com/LWLDD/p/6684616.html
Copyright © 2020-2023  润新知