Appendix B
Input and Output Process Example
The following example explains how to write a program that calculates the cost of painting a room. If the user provides the price of a gallon of paint; the number of square feet one gallon of paint covers; and the length, height, and width of the room, you can calculate the total cost of painting the room.
To calculate the total cost, determine the room area and divide the area to be painted by the number of square feet one gallon of paint covers. Then, multiply the number of gallons needed by the price per gallon to find the total cost. Provide the total cost to the user.
The following chart illustrates the data input and output process:
Input
Process
Output
Price
Square feet per gallon
Width
Length
Height
Get user input.
Price
Square feet per gallon
Width
Length
Height
Length
Height
Width
Find room area.
Total area
Square feet per gallon
Total area
Divide the area.
Gallons needed
Gallons needed
Price
Multiply gallons.
Total cost
Price
Square feet per gallon
Width
Length
Height
Total cost
Display the total.
Total cost