C SC 120: Introduction to Computer Programming
Winter 2009
Pete Sanderson
[
home
|
syllabus
|
schedule
|
catalog description
]
Alice in Action Chapter 4 Assignment : 20 points
Readings listed by textbook section number. Read while Alice is running.
- Section 4.1...Read: Topic is the use of Boolean (true/false) values in Alice. Read carefully; there are no examples programs to do.
- Section 4.2...Read and Do: Topic is selective flow control using the "if" control statement. Do the
dragon example in 4.2.3. Read 4.2.5 closely but there is no need to do its example (extends fish jumping example from 3.2, which we did not do).
- Section 4.3...Read and Do: Topic is repetition using the
"for" control statement. The dragon example here is
an extension of the wing-flapping dragon in Section 2.3.2 (Reusing an Object in a Different World). If you skipped that one, you'll need to do it now.
- Section 4.4...Read and Do: Topic is repetition using the "while" control statement. Finish the wing-flapping
example. You can skip the second example, the bouncing ball, if you wish. It is pretty cool, though.
- Section 4.5...Optional: Topic is flow control inside of functions. Recall that functions answer questions.
Programming Projects to do, listed by Programming Project number.
- Project 4.5: Build this new world then demo for
me. Use a "for" loop to input and accumulate the numbers. You will need a
numeric variable to accumulate the sum. Suppose the numeric variable nextNumber
holds the user's input number and the numeric variable sum is used
to accumulate the sum of all inputted numbers. The statement sum.set(
value, (sum + nextNumber) ); placed inside the "for" loop, will add the
value stored in nextNumber to the current value stored in sum
and store the result back into sum. When input is finished, sum
will contain the sum of all the inputted numbers (without having to keep all
of them). Save this program to your myFiles repository.
- Project 4.6: Modify the world from 4.5 as directed then demo for me. Use a "while" loop for input and accumulation.
In addition to the accumulator variable, you will need a numeric variable to keep track of how many numbers were inputted and increment it after each input. Make
sure that the last input value (-999) is not accumulated into the sum or counted in the input count (hint: use an IF statement). Save
this program to your myFiles repository.
[
C SC 120
|
Pete Sanderson
|
Math Sciences server
|
Math Sciences home page
|
Otterbein
]
Last updated:
Pete Sanderson (PSanderson@otterbein.edu)