Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

each program begins with stat and ends with stop must have 2 loops and 2 decisio

ID: 3626526 • Letter: E

Question

each program begins with stat and ends with stop must have 2 loops and 2 decision points
Start
get home
while you are tired
watch tv
endwhile
if you are hungry then
eat food
else
drink glass of wine
endif
if you did exercise then
do exercise
endif
if you need a shower then
take shower
else
drink glass of wine
endif
while you dont have work
go to bed
endif
stop


program two

Start
wake up
while incoherent
turn on radio
endwhile
if you smell bad then
take shower
else
get dressed
endif
if you want to work then
get in car
else
call in sick
endif
while car broke
call taxi
endif
stop

Explanation / Answer

Start
get home
while you are tired loop 1
watch tv
endwhile
if you are hungry then decision 1
eat food
else
drink glass of wine
endif
if you didn't exercise then that didn't make sense. Why would you exercise if you already did?
do exercise
endif
if you need a shower then decision 2
take shower
else
drink glass of wine
endif
while you dont have work I'm not sure what it means to go to bed multiple times or continuously in one night. You could sleep while you don't have work. loop 2
go to bed sleep
endif
stop


program two

Start
wake up
while incoherent loop 1
turn on listen to radio same problem as above - why would you turn on the radio multiple times?
endwhile
if you smell bad then decision 1
take shower
else
get dressed
endif
if you want to work then decision 2
get in car
else
call in sick
endif
while car broke
call taxi how many taxis are you going to call?
endif
while hungry loop 2
eat see how eating is repeatable?
endwhile
stop