中国高校课件下载中心 》 教学资源 》 大学文库

《Java程序设计》课程教学课件(PPT讲稿)第4章 循环

文档信息
资源类别:文库
文档格式:PPT
文档页数:48
文件大小:254.5KB
团购合买:点击进入团购
内容简介
《Java程序设计》课程教学课件(PPT讲稿)第4章 循环
刷新页面文档预览

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807 1 第4章 循 环

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807 2 引言 假设你需要打印一个字符串 (例如: “Welcome to Java!”)100次。这就需要把下面的 输出语句重复100遍,过程是相当繁琐: System.out.println("Welcome to Java!"); 所以,该如何解决这个问题?

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807 3 开放问题 System.out.println("Welcome to Java!"); System.out.println("Welcome to Java!"); System.out.println("Welcome to Java!"); System.out.println("Welcome to Java!"); System.out.println("Welcome to Java!"); System.out.println("Welcome to Java!"); . . . System.out.println("Welcome to Java!"); System.out.println("Welcome to Java!"); System.out.println("Welcome to Java!"); 问题: 100次

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807 4 介绍while循环 int count = 0; while (count < 100) { System.out.println("Welcome to Java"); count++; }

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807 5 学习目标 使用while循环编写重复执行某些语句的程序 (第4.2节)。 开发程序 GuessNumber(第4.2.1节)。 遵循循环设计策略来开发(第4.2.2节)。 开发程序SubtractionQuizLoop (第4.2.3节)。 使用标志值控制循环 (第4.2.3节)。 使用输入重定向而不是从键盘输入以获得大量输入(第4.2.4节)。 使用do-while语句编写循环(第4.3节)。 使用for语句编写循环(第4.4节)。 了解三种类型的循环语句相似处和不同点(第4.5节)。 编写嵌套循环(第4.6)。 学习最小化数值误差的技术(第4.7节)。 从多种多样的例子(GCD、FutureTuition、MonteCarloSimulation)中学 习循环(第4.8节)。 使用break和continue实现程序的控制(第4.9节)。 (GUI)使用确认对话框控制循环(第4.10节)

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807 6 while 循环流程图 while (循环继续条件){ // 循环体; 语句(组); } int count = 0; while (count < 100) { System.out.println("Welcome to Java!"); count++; } Loop Continuation Condition? true Statement(s) (loop body) false (count < 100)? true System.out.println("Welcome to Java!"); count++; false (A) (B) count = 0;

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807 7 跟踪while循环 int count = 0; while (count < 2) { System.out.println("Welcome to Java!"); count++; } 初始化 count 动 画

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807 8 跟踪while循环(续) int count = 0; while (count < 2) { System.out.println("Welcome to Java!"); count++; } (count < 2) 为真 动 画

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807 9 跟踪 while 循环(续) int count = 0; while (count < 2) { System.out.println("Welcome to Java!"); count++; } 输出 Welcome to Java 动 画

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 0132130807 10 跟踪 while 循环(续) int count = 0; while (count < 2) { System.out.println("Welcome to Java!"); count++; } count自增1 现在count 是1 动 画

刷新页面下载完整文档
VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
相关文档