Question: im looking for help with this step Add a function named get _ float ( ) to the program. This function should accept one argument,

im looking for help with this step Add a function named get_float() to the program. This function should accept one argument, which is a prompt like Enter monthly investment: . Then, this function should use the input function to get an entry from the user using the prompt thats passed to it, and the entry should be converted to a float value. Next, this function should check this entry to make sure its greater than 0. If it is, the entry is valid and the number should be returned to the calling statement. If it isnt, an appropriate error message should be displayed, and the user should enter another value. To make this work, the function should use a while statement that gets an entry until it is valid. into this code def get_float(prompt, low_value, high_value):
while true: float(input(prompt)
low_value >0,
def calculate_future_value(monthly_investment, yearly_interest, years):
# convert yearly values to monthly values
monthly_interest_rate = yearly_interest /12/100
months = years *12
# calculate future value
future_value =0.0
for i in range(months):
future_value += monthly_investment
monthly_interest = future_value * monthly_interest_rate
future_value += monthly_interest
return future_value
def main():
choice ="y"
while choice.lower()=="y":
# get input from the user
monthly_investment = float(input("Enter monthly investment:\t"))
yearly_interest_rate = float(input("Enter yearly interest rate:\t"))
years = int(input("Enter number of years:\t\t"))
# get and display future value
future_value = calculate_future_value(
monthly_investment, yearly_interest_rate, years)
print(f"Future value:\t\t\t{round(future_value, 2)}")
print()
# see if the user wants to continue
choice = input("Continue?(y/n): ")
print()
print("Bye!")
if __name__=="__main__":
main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!