Lab 3 - Performing Computation Using Functions
Due - February 23/24, 2003
In this lab, you will write a program that uses functions to perform basic computation. Your program will prompt the user for two numbers and calculate the sum, difference, average, and product of those numbers. Each calculation should be performed in a separate function. Each function should take as input the two numbers entered by the user. The output of each function should be the result of the calculation.
Your program should ask the user for two numbers and store them as doubles. As your program performs each computation, it should store each result and then call a function which will print all of the results for the user. Below is the output from a potential sample run of your program:
Enter a double (e.g., 34.56): 25.2
Enter a second double in the same format: 87.3
The sum of your numbers is 112.5.
The difference of your numbers is -62.1.
The average of your numbers is 56.25.
The product of your numbers is 2199.96.
Start by writing the documentation for each of your functions. For each function, you must specify the type and function of each input parameter and the type and function of the output. Next, write, compile, and test your code.
- Make sure that each function is well documented. Your documentation should specify the type and role of each of the input paramaters and ouput.
- Make sure a lab assistant (Dianne or I) has seen your program run.
- Copy and paste the output of your program to the bottom of your program itself. Make sure the output is a comment. That means, put a /* before the output and a */ after the output.
Sami Rollins