[SOLVED] Programming Exercise 3-1

$25

File Name: Programming_Exercise_3-1.zip
File Size: 226.08 KB

5/5 - (1 vote)

Programming Exercise 3-1

Programming Exercise 5-8
# Global constants for paint job estimator

FEET_PER_GALLON = 112

LABOR_HOURS = 8

LABOR_CHARGE = 35

# main module

def main():

# Local variables

pricePaint = 0.0

feetWall = 0.0

gallonPaint = 0

hourLabor = 0

costPaint = 0.0

costLabor = 0.0

# Get wall space

feetWall = float(input(Enter wall space in square feet: ))

# Get paint price

pricePaint = float(input(Enter paint price per gallon: ))

# Calculate gallons of paint

gallonPaint = int(feetWall / FEET_PER_GALLON) + 1

# Calculate labor hours

hourLabor = gallonPaint * LABOR_HOURS

# Calculate labor charge

costLabor = hourLabor * LABOR_CHARGE

# Calculate paint cost

costPaint = gallonPaint * pricePaint

# Print cost estimate

showCostEstimate(gallonPaint, hourLabor, costPaint, costLabor)

# The showCostEstimate function accepts gallonPaint, hourLabor,

# costPaint, costLabor as arguments and displays the corresponding

# data.

def showCostEstimate(gallonPaint, hourLabor, costPaint, costLabor):

# Local variable

totalCost = 0.0

# Calculate total cost

totalCost = costPaint + costLabor

# Display results

print (Gallons of paint: , gallonPaint)

print (Hours of labor: , hourLabor)

print (Paint charges: $ ,

format(costPaint, ,.2f), sep=)

print (Labor charges: $ ,

format(costLabor, ,.2f), sep=)

print (Total cost: $ ,

format(totalCost, ,.2f), sep=)

# Call the main function.

main()

_1255011348.vsd

main()
getSpace
(feetWall)
setHours
(gallonPaint, hourLabor)
End
Declare
pricePaint, feetWall, gallonPaint, hourLabor,
costPaint, costLabor
getSpace(Ref
inputSpace)
Return
Display enter
wall space in
square feet
Input
inputSpace
showIncome
(gallonPaint, hourLabor,
costPaint, costLabor)
Return
Display gallons of paint: ,
gallonPaint
Display hours of labor: ,
hourLabor
Display paint charges: $,
costPaint
Display labor charges: $,
costLabor
Display Total Cost: $, totalCost
Global Constant Real
FEET_PER_GALLON
LABOR_HOURS
LABOR_CHARGE
showIncome(gallon
Paint, hourLabor,
costPaint, costLabor)
setHours
(gallonPaint, hourLabor)
Return
Set hourLabor = gallonPaint *
LABOR_HOURS
getPrice
(pricePaint)
setPaint
(feetWall,
gallonPaint)
setLaborCharge
(hourLabor, costLabor)
setPaintCharge
(gallonPaint, costPaint)
getPrice
(Ref inputPrice)
Return
Display enter
paint price per
gallon
Input
inputPrice
setPaint
(feetWall, gallonPaint)
Return
Set gallonPaint =
feetWall /
FEET_PER_GALLON
setLaborCharge
(hourLabor, costLabor)
Return
costLabor = hourLabor *
LABOR_CHARGE
setPaintCharg
e(gallonPaint, pricePaint,
Ref costPaint)
Return
Set costPaint =
gallonPaint * pricePaint
Declare
totalCost
Set totalCost =
costPaint + costLabor

main()

getSpace
(feetWall)

setHours
(gallonPaint, hourLabor)

End

Declare
pricePaint, feetWall, gallonPaint, hourLabor, costPaint, costLabor

getPrice
(pricePaint)

setPaint
(feetWall, gallonPaint)

getSpace(Ref inputSpace)

Input
inputSpace

showIncome
(gallonPaint, hourLabor, costPaint, costLabor)

Return

Return

Display enter wall space in square feet

Set totalCost =
costPaint + costLabor

setLaborCharge
(hourLabor, costLabor)

setPaintCharge
(gallonPaint, costPaint)

Display gallons of paint: , gallonPaint
Display hours of labor: , hourLabor
Display paint charges: $, costPaint
Display labor charges: $, costLabor
Display Total Cost: $, totalCost

Global Constant RealFEET_PER_GALLONLABOR_HOURS LABOR_CHARGE

getPrice
(Ref inputPrice)

Return

Display enter paint price per gallon

Input
inputPrice

showIncome(gallon
Paint, hourLabor, costPaint, costLabor)

setHours
(gallonPaint, hourLabor)

Return

Set hourLabor = gallonPaint * LABOR_HOURS

setPaint
(feetWall, gallonPaint)

setLaborCharge
(hourLabor, costLabor)

Return

costLabor = hourLabor * LABOR_CHARGE

Return

Set gallonPaint = feetWall / FEET_PER_GALLON

setPaintCharg
e(gallonPaint, pricePaint, Ref costPaint)

Return

Set costPaint =
gallonPaint * pricePaint

Declare
totalCost

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] Programming Exercise 3-1
$25