Structures
Classwork
In a text document:
1. For each of the following, would it be easiest to implement with a
conditional or a loop?
- keep dividing a number by two until you get down to an odd value
- print whichever of two numbers is lower
- print a list of 100 names
- get a list of prices from the user and add them all up
- check whether an attack was high enough to hit and if so
subtract hit points
- add a surcharge for a user who doesn't have a loyalty card
2. For each of the following, what name and parameters should a method
(module) to do it be given?
e.g. a method that finds the highest of
three numbers might be findMax(num first, num second, num third)
- print a certificate of appreciation for help given by a certain
person on a certain date
- calculate the interest on a bank balance
- find the volume of a
cone