Sale!

Homework I: Compounding Interest Calculator solved

$35.00 $21.00

Category:

Description

5/5 - (1 vote)

#Part A
Build a simple calculator for runners to determine how long it will take to run a distance.
1. Ask the user how far she/he will run;
2. Ask the user to enter the desired pace in minutes per mile or kilometer;
3. Calculate how long it will take the user to complete the run; and
4. Print the results.
For simplicity, seconds can be expressed as decimals, for example, 7.5 can be used for 7 minutes 30
seconds.
Output example (if you’ve coded it correctly, your output should look something like this):
How far will you run? 13.1
How fast will you run (please enter decimal, like 7.5 for 7:30 pace)? 7.25
It will take you 94.975 minutes to run 13.1
#Part B
Frequently in business, we want to calculate the future value of an investment or loan after interest has
compounded. The equation to do this is:
Where A is the future value,
P is the principal (initial amount invested or borrowed)
r is the annual rate of interest as a decimal
n is the number of times the interest rate compounds per year
t is the term of the loan or the number of years before it is repaid
We want to build a calculator that will:
1. Ask the user to input the values for the variables above;
2. Perform the calculation; and
3. Print the following string to the user:
In [t] years, at the interest rate of [r] compounded [n] times per year, the initial amount
of [P] will be worth [A]
Example:
In 5 years, at the interest rate of 5% compounded 4 times per year, the initial amount of
$5000.00 will be worth $6410.19
Note that the figures in this string have been formatted to include only two decimals and a dollar
symbol.
You can check the results of your script by using an online future value calculator, like this one. If you do
so, leave the annual addition amount at 0 and select ‘start’ as the ‘Make additions at’ option.
Output Example:
Please enter principle:
4000
Please enter annual interest rate (example 5.2 for 5.2%):
5.2
Please enter the term in years:
5
Please enter number of times the interest will compound per year:
365
In 5.0 years, at the interest rate of 5.2% compounded 365 times per year, the initial amount of
$4,000.00 will be worth $5,187.62.
Extra challenge:
If this assignment was easy, you can also calculate the amount paid to interest. Extra challenges are not
necessary to receive full credit on homework and labs.
Extra Challenge Output example:
In 5.0 years, at the interest rate of 5.2% compounded 365 times per year, the initial amount of
$4,000.00 will be worth $5,187.62. $1,187.62 will be paid in interest.