The For Loop The For Loop by Emily Austin Austin Programming gI Course: Java Programmin Unit: Control St Structures II II Topic: The for loop: loop: single and nested Class Duration: 50 minut nutes th Grade Level: 10 1!th Objective The students "ill be able to edit# save# com$ile and run a co com$uter m$uter $rogram "ritten in the $rogramming language Java to code a solution using the %or loo$ construct& The students "ill also be able to do the same thing using nested %or loo$s& They "ill achieve these ob'ectives ob'ectives using (lueJ& Materials )esson Plan *hite board +ry erase mar,ers Com$uters "ith (lueJ *or,sheet *o r,sheet -1 .Java code that $rints out %ive ro"s o% asteris,s# asteris,s# ten "ide& The number o% the ro" is the %irst thing to be $rinted in the ro"# %ollo"ed by the asteris,s&/ Conversion Table Table Assignment Background This lesson assumes the level at "hich a student can read is at least euivalent to that o% a ty$ical 5 th grade student& In order to be success%ul in this lesson# a student must have the %ollo"ing $rior ,no"ledge: use o% (lueJ# understanding o% e$ressions and statements# Strings# (oolean o$erators# and i%2else 3structure4& Procedures
1& Preassessment A& Short revie" o% e$ressions and statements (& Short revie" o% (oolean o$erators C& Pose the uestion: 3o" might you $rint out %ive ro"s o% asteris,s# ten "ide64 !& )ecture A& (asic for loop synta for # $air o% $arentheses "ith se$arating semicolons# body o% loo$ surrounded by curly brac,ets initiali7ation o% loo$ control variable test condition that controls loo$ entry • di%%erent "ays to to init8test i90 vs& i91 and i5 vs& i95 e$ression that .ho$e%ully/ alters the loo$ control variable (& (asic for (asic for loop logic loop logic
Initiali7ation "ill al"ays eecute "hen a for a for loop is loop is encountered& It only eecutes once& I% the test condition is true true## then the body o% the loo$ is entered& I% the test condition is false is false## then 3go to4 the line o% code that immediately %ollo"s the for loop body& loop body& A%ter the body o% the for the for loop is loop is eecuted# the loo$ control variable is u$dated& )oo$ bac, to the test condition continuously until it is false is false&&
C& S$ecial .or $it%alls/ Etracases semicolon in a statement %or .int i90; i5; i
Thank you for interesting in our services. We are a non-profit group that run this website to share documents. We need your help to maintenance this website.