Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a program that uses a function named fv ( ) to calculate and output the future values ( future _ value ) given a

Create a program that uses a function named fv() to calculate and output the future values (future_value) given a principal amount (p), rate of interest (r), and the number of years (years) as its parameters. The formula for the future value is:
future_value = p *((1+(0.01*r))** years )
In other words, the function fv() has three parameters p, r, and years.
Additional requirements:
The principal amount (p) in the function definition has a default value of 1000(that is, the argument for this parameter is optional).
The interest rate (r) in the function definition has a default value of 2.5(another optional argument).
**Note that in a function definition, parameters with default values must appear AFTER parameters without default values.
At the beginning of the program, first use the input() function to prompt users for the time period in years.
Use while loop to validate user inputs. If the time period a user inputted is less than 1, print out You must enter a value greater than or equal to 1. Then, prompt the user to enter the time period again. The program execution leaves the loop only when a user entered a value >=1.
When calling the function, only provide one argument: which is the time period (year) the user inputted:
fv(year)
**In other words, use the default principal value (p) and interest rate (r)(see items A and B above) for calculating the future value.
F. Round the future value to two decimal places.
For example: If you type in a wrong value, you will see a warning message until you enter a value that is greater than or equal to 1.
Please enter the time period in years: 0
You must enter a value greater than or equal to 1.
Please enter the time period in years: -5
You must enter a value greater than or equal to 1.
Please enter the time period in years: 6
Future value after 6 years is 1159.69

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

Students also viewed these Databases questions

Question

What is the y-intercept?

Answered: 1 week ago