第03章 入门准备 Java JDK 6 教学课件.pptVIP

  • 1
  • 0
  • 约1.22万字
  • 约 44页
  • 2018-01-28 发布于浙江
  • 举报
第03章 入门准备 Java JDK 6 教学课件

* * * * * * * * * * * * * * * * * * * * * * * * * if条件式 语法 复合陈述句 if(条件式) 陈述句一; else 陈述句二; if(条件式) { 陈述句一; 陈述句二; } else { 陈述句三; 陈述句四; } if条件式 Scanner scanner = new Scanner(System.in); System.out.print(请输入数字: ); int input = scanner.nextInt(); int remain = input % 2; //求除2的余数 if(remain == 1) //如果余数为1 System.out.println(input +为奇數); else System.out.println(input +为偶數); if条件式 if中再设定执行的条件 if(条件式一) { 陈述句一; if(条件式二) 陈述句二; 陈述句三; } if(条件式一) { 陈述句一; //其它陈述句 } else if(条件式二) 陈述句二; if(条件式一) { 陈述句一; //其它陈述句 } else if(条件式二) 陈述句二; if条件式 Scanner scanner = new Scanner(System.in); System.out.print(输入分数:); int score = scanner.nextInt(); if(score = 90) System.out.println(得A); else if(score = 80 score 90) System.out.println(得B); else if(score = 70 score 80) System.out.println(得C); else if(score = 60 score 70) System.out.println(得D); else System.out.println(得E(不及格)); switch条件式 switch的语法架构 switch(变量名称或表达式) { case符合数字或字符: 陈述句一; break; case符合数字或字符: 陈述句二; break; default: 陈述三; } Scanner scanner = new Scanner(System.in); System.out.print(请输入分數: ); int score = scanner.nextInt(); int level = (int) score/10; switch(level) { case 10: case 9: System.out.println(得A); break; case 8: System.out.println(得B); break; case 7: System.out.println(得C); break; case 6: System.out.println(得D); break; default: System.out.println(得E(不及格)); for循环 基本语法 for(初始式;判断式;递增式) { 陈述句一; 陈述句二; }

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档