码迷,mamicode.com
首页 > 其他好文 > 详细

课堂复习内容(2)

时间:2017-04-09 14:36:47      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:ring   exti   style   demo   nbsp   嵌套   复习   输出   ann   

                                                                           选择结构

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("淘汰!!");
                                           }
                                         }
                                    }

       

 

课堂复习内容(2)

标签:ring   exti   style   demo   nbsp   嵌套   复习   输出   ann   

原文地址:http://www.cnblogs.com/LWLDD/p/6684616.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!