Calculate the annual interest rate in a savings account

User Generated

nyznxl

Programming

Description

Aunt Agatha left you some cash. You decide to do the boring thing and deposit the money in a savings account. In this assignment write a program that calculates how much money would be in the account as it accrues interest year after year.

The program should take as input:

  • The amount of money Aunt Agatha left you, i.e., the starting balance in the account.
  • The annual interest rate.
  • The number of years to save.

The program should output the amount of money that you'd have in each of the years saved at the given annual rate should interest be compounded either yearly, monthly, or daily.

Unformatted Attachment Preview

CIS 1068 Assignment 4. Nest Egg. https://cis.temple.edu/~jfiore/2017/fall/1068/assignments/04/ CIS 1068 Assignment 4 Nest Egg Due: Monday, October 2 40 points description Aunt Agatha left you some cash. You decide to do the boring thing and deposit the money in a savings account. In this assignment, you'll write a program that calculates how much money would be in the account as it accrues interest year after year. The program should take as input: The amount of money Aunt Agatha left you, i.e., the starting balance in the account. The annual interest rate. The number of years to save. The program should output the amount of money that you'd have in each of the years saved at the given annual rate should interest be compounded either yearly, monthly, or daily. a sample run What is the starting balance (in dollars)? 10000 What's the yearly interest rate (in percent)? 5 For how many years will you be saving? 30 Using: starting balance - 10000.0 yearly interest rate - 5.0 years to save - 30 | year | yearly | monthly | daily | | 1|$10500.00|$10511.62|$10512.67| | 2|$11025.00|$11049.41|$11051.63| | 3|$11576.25|$11614.72|$11618.22| | 4|$12155.06|$12208.95|$12213.86| | 5|$12762.82|$12833.59|$12840.03| | 6|$13400.96|$13490.18|$13498.31| | 7|$14071.00|$14180.36|$14190.34| | 8|$14774.55|$14905.85|$14917.84| | 9|$15513.28|$15668.47|$15682.64| | 10|$16288.95|$16470.09|$16486.65| | 11|$17103.39|$17312.74|$17331.88| | 12|$17958.56|$18198.49|$18220.44| | 13|$18856.49|$19129.56|$19154.56| | 14|$19799.32|$20108.26|$20136.56| | 15|$20789.28|$21137.04|$21168.91| | 16|$21828.75|$22218.45|$22254.19| | 17|$22920.18|$23355.19|$23395.11| | 18|$24066.19|$24550.08|$24594.52| | 19|$25269.50|$25806.11|$25855.41| | 20|$26532.98|$27126.40|$27180.96| | 21|$27859.63|$28514.24|$28574.46| | 22|$29252.61|$29973.08|$30039.40| | 23|$30715.24|$31506.56|$31579.44| | 24|$32251.00|$33118.50|$33198.44| | 25|$33863.55|$34812.90|$34900.44| | 26|$35556.73|$36594.00|$36689.70| 1 of 2 9/28/17, 3:40 PM CIS 1068 Assignment 4. Nest Egg. | | | | https://cis.temple.edu/~jfiore/2017/fall/1068/assignments/04/ 27|$37334.56|$38466.22|$38570.69| 28|$39201.29|$40434.22|$40548.11| 29|$41161.36|$42502.91|$42626.91| 30|$43219.42|$44677.44|$44812.29| calculating compound interest If interest is compounded yearly, the amount of money that you'll have in the account will be the amount that you had last year plus the interest rate times last year's balance. For example, suppose that you had $100 last year, and the interest rate is 5 percent. The amount of interest that you've earned is 0.05*$100 = $5. If interest is compounded monthly, you'll receive interest payments each month instead of each year. Remember, that the monthly interest rate is the annual rate divided by 12. So, using the previous example of an annual interest rate of 5%, if interest is compounded monthly, each month you'd receive an additional 0.05/12=0.004167 interest payment. Similarly, if interest were to be compounded daily, each day, you'd add an additional fraction of 0.05/365 to your previous days' balance. You may already know or can easily look up a formula for calculating compound interest, but you can also calculate the values in the table using the simple way that you learned in grade school along with some loops. At each step, think: the amount of money I have now is the same as the amount I had before, plus the interest I've earned in the meantime. formatted output Though it's not required for the assignment, to format the output as it appears in the sample, you can use the Formatter class. To use it, you need to: import java.util.Formatter; The code used to print a single line in the table is: System.out.format("|%6d|$%.2f|$%.2f|$%.2f|\n", i, yearlyAmt, monthlyAmt, dailyAmt); where i, yearlyAmt, monthlyAmt, and dailyAmt are the variables representing the number of years the money has accrued interest, and the balance after that many years has elapsed if interest was compounded yearly, monthly, or daily. If you decide that you'd like to use this, replace i, yearlyAmt, monthlyAmt, and dailyAmt with the variables that you've chosen to represent the year, yearly-, monthly-, and daily-compounded totals. 2 of 2 9/28/17, 3:40 PM
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

Hello, here is your code. I...


Anonymous
Super useful! Studypool never disappoints.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags