88.3k views
5 votes
How much paint?

A gallon of paint covers 422 square feet and costs $29.85. Using flowgorithm
determine and display the amount of paint it will take to paint a fence of a
specified height and length, the fence is solid not rails.
Your flowgorithm should perform the following tasks:

 Declare all required variables
 Declare constants and initialize them
 Prompt for the input of the fence height
 Prompt for the input of the fence length
 Calculate the total square feet to be painted
 Calculate the required number of gallons of paint required, you cannot
purchase a partial gallon of paint**
 Display, with appropriate output labels, the total square feet to be painted,
the number of gallons of paint needed and the total cost of the paint
 Ask if a second estimate needs to be made (keep program running until told
to stop)
**modulo operator perhaps

Remember the following:
 make sure your calculations are correct
 use clear prompts for your input
 label each output number or name

User Duckduckgo
by
8.2k points

1 Answer

2 votes

Answer:

program PaintCalculator

// Declare variables

height : real

length : real

area : real

gallons : integer

cost : real

answer : char

// Declare constants

SQ_FT_PER_GALLON : integer = 422

PRICE_PER_GALLON : real = 29.85

repeat

// Prompt for input

output "Enter the height of the fence in feet: "

input height

output "Enter the length of the fence in feet: "

input length

// Calculate area and gallons needed

area <- height * length

gallons <- area / SQ_FT_PER_GALLON

if area % SQ_FT_PER_GALLON > 0 then

gallons <- gallons + 1

end if

// Calculate cost

cost <- gallons * PRICE_PER_GALLON

// Output results

output "Total square feet to be painted: " + area

output "Gallons of paint needed: " + gallons

output "Total cost of paint: $" + cost

// Ask if user wants to continue

output "Do you want to make another estimate? (Y/N)"

input answer

until answer = 'N'

end program

User Drew Kroft
by
8.9k points