Lecture 7:  Functions

Activity:  Problem Recognition Task

In today's lecture, we learned why functions are useful in programming.  Examine the formatting of the cost reports shown below.  (Ignore the funny names -- they are taken from the Harry Potter series.)  List any functions that might be useful in generating these reports (don't worry about the computational aspect of calculating the numbers; focus on functions that aid in the printing/formatting of the information).  Please list the function name that would be appropriate, a description of what the function does, and reasons why you think this is a helpful function.  Don't worry about writing any C code here.  We'll learn more about functions in the next lecture.

==============================================================================
How many ounces of wormwood are needed? 0
How many ounces of nettles are needed? 5.0
How many snake fangs are needed? 20
How many horned slugs are needed? 0
How many porcupine quills are needed? 20
How many potion vials are needed? 10

*-----*-----*-----*-----*-----*
MalWart:
        Item        Quantity
*-----*-----*-----*-----*-----*
Snake Fangs          20.00
Porcupine Quills     20.00
Potion Vials         10.00
*-----*-----*-----*-----*-----*
 

Hit any key, then enter to continue
x

*-----*-----*-----*-----*-----*
California Dreams:
        Item        Quantity
*-----*-----*-----*-----*-----*
Nettles (in oz.)      5.00
*-----*-----*-----*-----*-----*
 

Hit any key, then enter to continue
x

*-----*-----*-----*-----*-----*
Local price list:
        Item        Ga Si Kn
*-----*-----*-----*-----*-----*
Snake Fangs          0 10 28
Porcupine Quills     0  2 11
Potion Vials         0 10  9
Nettles (in oz.)     0  9 16
*-----*-----*-----*-----*-----*
 

Hit any key, then enter to continue
x
==============================================================================

To get you started, here is an example function.

Function Name:  PrintSeparator

Description:  This function prints the line
*-----*-----*-----*-----*-----*
to use as a separator line in the reports.

Helpfulness:  If a person wanted to change the separator to be all asterisks, this could be done easily if the line is printed using a function.