Programming Exercise 3-1
Programming Exercise 5-3
# Global constant for the percent of replacement cost
REPLACE_PERCENT = 0.8
# main def
def main():
# Local variables
replace= 0.0
minInsure = 0.0
# Get the replacement cost.
replace = float(input(‘Enter the replacement amount: ‘))
# Calculate the insurance amount
minInsure = replace * REPLACE_PERCENT
# Print information about the insurance.
showInsure(replace, minInsure)
# The showInsure function accepts the replace value
# and the minimum recommended insurance as arguments
# and displays the transaction information.
def showInsure (replace, minInsure):
print (‘Replacement cost: $’, \
format(replace, ‘,.2f’), sep=”)
print (‘Percent insured: $’, \
int(REPLACE_PERCENT * 100), \
‘%’, sep=”)
print (‘Minimum insurance: $’, \
format(minInsure, ‘,.2f’), sep=”)
# Call the main function.
main()
_1254835599.vsd
main()
getReplace
(replace)
showInsure
(replace, minInsure)
End
Declare
replace, minInsure
getReplace
(Ref inputReplace)
Return
Display “Enter
the
replacement
amount.”
Input
inputReplace
showSale
(replace, minInsure)
Return
Display
“replacement cost: $”, replace
“percent insured: “,
REPLACE_PERCENT
“minimum insurance: “,
minInsure
Global Constant Real
REPLACE_PERCENT
setInsure
(replace, minInsure)
setInsure (replace,
Ref minInsure)
Return
Set minInsure = replace
* REPLACE_PERCENT
main()
getReplace
(replace)
showInsure
(replace, minInsure)
End
Declare
replace, minInsure
getReplace
(Ref inputReplace)
Input
inputReplace
showSale
(replace, minInsure)
Return
Return
Display “Enter the replacement amount.”
Display
“replacement cost: $”, replace
“percent insured: “, REPLACE_PERCENT
“minimum insurance: “, minInsure
Global Constant Real REPLACE_PERCENT
setInsure
(replace, minInsure)
setInsure (replace,
Ref minInsure)
Return
Set minInsure = replace * REPLACE_PERCENT