BUILDING JAVA PROGRAMS CHAPTER 2 Days of For Loops Past.

Download BUILDING JAVA PROGRAMS CHAPTER 2 Days of For Loops Past.

Post on 16-Jan-2016

215 views

Category:

Documents

0 download

TRANSCRIPT

PowerPoint Presentation

Building Java ProgramsChapter 2Days of For Loops Pastdays until the AP Computer Sciencetest2275488hoursReview of Project 1.3

Review of Project 1.3 (Rubric)Code is clearly commented, including your name and class period (1 point)Program compiles (1 point)Program produces the correct output (1 point)Use methods for each verse and the refrain (1 point)Repetitive code is isolated into methods (1 point)

Review of Project 1.3 (Rubric)Code is clearly commented, including your name and class period (1 point)Program compiles (1 point)Program produces the correct output (1 point)Use methods for each verse and the refrain (1 point)Repetitive code is isolated into methods (1 point)

Review of Project 1.3 (Common Errors)Program compiles (1 point)The public type OldLady must be defined in its own file.

JD_Proj_1_3.java

public class OldLady { }Filename and class name must match!Review of Project 1.3 (Rubric)Code is clearly commented, including your name and class period (1 point)Program compiles (1 point)Program produces the correct output (1 point)Use methods for each verse and the refrain (1 point)Repetitive code is isolated into methods (1 point)

Review of Project 1.3 (Rubric)Code is clearly commented, including your name and class period (1 point)Program compiles (1 point)Program produces the correct output (1 point)Use methods for each verse and the refrain (1 point)Repetitive code is isolated into methods (1 point)

Review of Project 1.3 (Common Errors)Use methods for each verse and the refrain (1 point)

public class OldLady { public static void main(String args[]) { System.out.println(There was an old lady who swallowed a fly.); flyRefrain();

System.out.println(There was an old lady who swallowed a spider.); }}Review of Project 1.3 (Rubric)Code is clearly commented, including your name and class period (1 point)Program compiles (1 point)Program produces the correct output (1 point)Use methods for each verse and the refrain (1 point)Repetitive code is isolated into methods (1 point)

Review of Project 1.3 (Common Errors)Repetitive code is isolated into methods (1 point)

public class OldLady { public static void spiderRefrain(String args[]) { System.out.println(She swallowed the spider to catch the fly.); }

public static void birdRefrain(String args[]) { System.out.println(She swallowed the bird to catch the spider.); }

public static void cowVerse() { cowRefrain(); dogRefrain(); catRefrain(); birdRefrain(); }

}ObjectivesAt the end of you class you will be able toWrite for loops with multiple statements in the body.Describe when to use for loops with complex expressions.Trace the program flow of programs with nested for loops.

Simple for loop (Review)for (int count = 1; count