Structures


Classwork

In a text document:

1. For each of the following, would it be easiest to implement with a conditional or a loop?

  1. keep dividing a number by two until you get down to an odd value
  2. print whichever of two numbers is lower
  3. print a list of 100 names
  4. get a list of prices from the user and add them all up
  5. check whether an attack was high enough to hit and if so subtract hit points
  6. add a surcharge for a user who doesn't have a loyalty card

 

2. For each of the following, what type, 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
int findMax(int first, int second, int third)

  1. print a certificate of appreciation for help given by a certain person on a certain date
  2. calculate the interest on a bank balance
  3. find the volume of a cone