Chapter 3 5, 9 ==Constants 1 gallon paint per 115 sq ft or 115 sq ft per 1 gallon Constant Real SQFT_PER_GALLON = 115 8 hours labor per 115 sq ft Constant Real SQFT_PER_HOUR = 115 / 8 Constant Real SQFT_PER_HOUR = 14.375 $20 dollars per hour for labor Constant Real COST_PER_HOUR = 20 ==Inputs sqFtPainted pricePerGallon ==Process gallonsNeeded = sqFtPainted / SQFT_PER_GALLON hoursRequired = sqFtPainted / SQFT_PER_HOUR costPaint = gallonsNeeded * pricePerGallon costLabor = hoursRequired * COST_PER_HOUR costTotal = costPaint + costLabor ==Outputs gallons of paint required Real gallonsNeeded hours of labor required Real hoursRequired cost of the paint Real costPaint cost of labor charges Real costLabor cost total of the job Real costTotal =Top Down Design showIntro() getInputs() calcGallonsNeeded() calcHoursForJob() calcCostPaint() calcCostLabor() showResults() // Global constants for Sq Ft. per Gallon and Sq Ft per Hour Constant Real SQFT_PER_HOUR = 14.375 Constant Real SQFT_PER_GALLON = 115 Constant Real COST_PER_HOUR = 20 // main module Module main() // Local Variables Declare Real sqFtPainted, pricePerGallon, gallonsNeeded Declare Real costPaint, costLabor, hoursRequired // Show intro Call showIntro() // Get the price for the paint and per Gallon Call getInputs(sqFtPainted, pricePerGallon) // Calculate the gallons needed which will be passed by Reference // We will see this when we write the function Call calcGallonsNeeded(sqFtPainted, gallonsNeeded) // Calculate the hours needed to complete the job which // *hoursRequired* passed by Reference Call calcHoursForJob(sqFtPainted, hoursRequired) // Calculate the cost of the paint // *costPaint* passed by Reference Call calcCostPaint(gallonsNeeded, pricePerGallon, costPaint) // Calculate the cost of the labor // *costLabor* passed by Reference Call calcCostLabor(gallonsNeeded, costLabor) // Show the results // Everything passed by value Call showResults(gallonsNeeded, hoursRequired, costPaint, costLabor) End Module // main Module showIntro() Display "This is the pain program that will calculate gallons needed," Display "hours required to complete the job, and calculate the price" Display "of the paint, the labor, and the total cost" Display "User inputs area to be painted and the price per gallon for paint" End Module // showIntro() Module getInputs(Real Ref areaPainted, Real Ref pricePerGallon) Display "Enter the area painted in Square Feet" Input areaPainted Display "Enter the price per gallon for the paint" Input pricePerGallon End Module Module calcGallonsNeeded(Real area, Real Ref gallonsNeeded) gallonsNeeded = area / SQFT_PER_GALLON End Module Module calcHoursForJob(Real area, Real Ref hoursRequired) hoursRequired = area / SQFT_PER_HOUR End Module Module calcCostPaint(Real gallonsNeeded, Real pricePerGallon, Real ref costPaint ) costPaint = gallonsNeeded * pricePerGallon End Module Module calcCostLabor(Real hoursRequired, Real ref costLabor ) costLabor = hoursRequired * COST_PER_HOUR End Module // Output the results to our user module showResults(Real gallonsNeeded, Real hoursRequired, Real costPaint, Real costLabor) Declare Real total total = costPaint + costLabor Display "The gallons of paint required is ", gallonsNeeded Display "The hours of labor required is ", hoursRequired Display "The cost of the paint is ", costPaint Display "The cost of the labor is ", costLabor Display "The total cost is ", total End Module