Page 79 - Introduction to Programming with Java: A Problem Solving Approach
P. 79

                Figure 2.15 Happy Birthday trace—long form
2.11 Tracing 45
 7
8
5
6
1
2
print“Whatisyourname?” inputname
setcountto0 whilecountislessthan2
print “Happy birthday to you.”
set count to count + 1 print“Happybirthday,dear”name“.” print“Happybirthdaytoyou.”
3
4
input Arjun
    line#
name
count
output
     1
What is your name?
    2
Arjun
    3
0
    5
Happy birthday to you.
    6
1
      5
  2
Happy birthday to you.
  6
     7
Happy birthday, dear Arjun.
  8
  Happy birthday to you.
Apago PDF Enhancer
 5
6
7
1
2
print“Enterlastname(qtoquit):” inputlastName whilelastNameisnotequaltoq
if lastName’s first character is between A and M print lastName “ is assigned to Chestnut Hall.”
else
print lastName “ is assigned to Herr House.”
3
4
input Ponce Galati Aidoo Nguyen q
 line#
 lastName
 output
 Figure 2.16 Freshmen dormitory assignment algorithm and trace setup













































   77   78   79   80   81