学学习网 手机版

学学习网

学习路径: 学习首页 > 应用开发 > java >

第四节 流程控制(2)

设置字体:
----------------------------------

                            break; //break ,表示跳出switch
                      case  'b':
                            System.out.println("今天星期二");
                            break;
                      case  'c':
                            System.out.println("今天星期三");
                            break;
                      default:
                            System.our.println("不知道星期几");
                            break;
                  }
           例5:
                 import java.io.*;
                 public class text2
                 {
                     public static void main (String []args) throws Exception
                      {
                        String str;
                        int a;
                        BufferedReader buf;
                        buf=newBufferedReader (new InputStreamReader(System.in));                                 
                        str=buf.readLine();        
                        a=Integer.parseInt(str);
                        switch (a)
                         {
                           case a<=100 && a>=90:System.out.println("优");break;
                           case a<90 && a>=80:  System.out.println("良");break;
                           case a<80 && a>=70:  System.out.println("中");break;
                           case a<70 && a>=60:  System.out.println("及格");break;
----------------------------------
课程列表
重点难点
赞助链接