Practice Exercise: Programmer-defined Functions--application
Instructions
Write a program to estimate furniture moving costs according to the problem
specifications and design constraints specified below.
User Interface
Prepare a menu of choices to: collect user input, compute labor charge,
compute travel charge, and print a report summary.
Input
Collect client name, moving distance in miles, and furniture weight.
Output
Output a descriptive heading line stating the program purpose. Follow this
with user prompts for distance and weight. After calculating moving costs,
print a report summary that includes name, labor charge, travel charge, and
total moving charge. Include column headings or side labels to identify the
computed information.
Processing
1. Output a heading line with the program purpose.
2. Accept user inputs for name, weight in pounds, and distance in miles.
3. Call a type double function named computeLaborCharge that accepts weight as
a parameter and returns the labor charge.
Labor charge is the product of labor rate times pounds (100 lb minimum).
4. Call a function to compute travel charge. The travel charge computed is a
base travel fee plus mileage rate times distance in miles (5 mile minimum).
5. Compute total moving charge as the sum of labor charge and travel charge.
6. Call a function to print the report summary.
Design Constraints
1. Insert a block comment at the top of your source program with the program
name, your name, the course code, and the problem identifier. Also insert
one or more line comments to document your code.
2. Make descriptive data names, use conventional case notation for variables,
initialize variables, define program constants for labor rate--$1.00 per
100wt, base travel fee--$50.00, and mileage rate--$2.00 per mile). Name
these program constants using uppercase letters and with underscores as
word separators.
3. Indent and align statements for readability and to show hierarchy.
4. Use a sentinel-controlled loop to allow the entire process to be repeated
for different moving scenarios.
5. Develop and invoke functions to: compute labor charge, travel charge,
and to output a moving charge summary.