Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Compound interest is a central feature of business and finance. This simple assi

ID: 3627390 • Letter: C

Question

Compound interest is a central feature of business and finance. This simple assignment is designed to help you learn about one aspect of compounding: how compounding works if you vary the compounding period of a sum of deposited money.

Suppose you deposit $1000 in your bank account for 1 year at 6% interest, compounded yearly. Then you will have $1060 at the end of the year. But what if you compound it monthly? Then you will get 1/12 of the accrued interest (1/2 of 1%) at the end of the first month (and so you will then have $1005 on the first of February)Then, on the first of March, you will get 1/2 of 1% of $1005 (and therefore a bit more than $1010) on the first of March, since the $5 you earned in January will also earn a little interest.

Mathematically, if you put $1000 in the bank, and you pay an interest rate of r, compounded into t blocks, then this expression:

1000 * (1 + r/t)(1 + r/t).......(1 + r/t) = 1000*(1 + r/t)t

tells how much money accumulates during the year.

Thus, to see how much money you earn if you put $1000 in the bank at 6%, compounded monthly, you need to calculate this:

1000 * (1 + .06/12)12

For daily interest compounding, you would need to calculate this expression to determine your sum after a year:

1000 * (1 + .06/365)365

(This says: on the first day, you earn 1/365 of 6%; this becomes your new sum; then, on the second day, you earn 1/365 of 6% on that, and so forth).

Your job, then, for this assignment is to use the Scanner class to read in three values to your program: an initial sum ($1000, above); a yearly rate of interest (.06, or 6%, above); and a term, or fraction of a year over which the compounding will take place (e.g. monthly - 12 equal time periods, or daily, 365 equal time periods).

Given these intial values, your program should report the value of your money at the end of the year.

Here is a sample run:

enter initial amount <1000 entered>
enter rate as a decimal - e.g. .06 <.06> entered
enter division period <365 entered>
final sum: $1,061.83

Some further tips:

You can use the Math class method pow(a,b). You can find out more about this method at:
the Java API documentation for Math.pow(a,b)
Decimal Formatting in Java requires a little bit of work. The baby program below prints some money amounts. Notice that you need to import the DecimalFormat class to get a nice display. Here we insist that you use this exact format descriptor: "$#,###.00".

import java.util.*;
import java.text.DecimalFormat;

public class MoneyDemo{
public static void main(String[] args) {
DecimalFormat d = new DecimalFormat("$#,###.00"); //prints amt to 2 decimal places, with $, commas
Scanner s = new Scanner(System.in);
System.out.println("enter amount");
double amt = s.nextDouble();
System.out.println(d.format(amt));
}
}


Now type in or copy and paste your code for the MoneyDemo class in the input box below.
IMPORTANT! the import statements are provided, so you should only provide the class definition, which, of course, should include main.

Explanation / Answer

please rate - thanks

import java.util.*;
import java.text.DecimalFormat;

public class MoneyDemo{
public static void main(String[] args) {
DecimalFormat d = new DecimalFormat("$#,###.00"); //prints amt to 2 decimal places, with $, commas
Scanner s = new Scanner(System.in);
double balance,rate,sum;
int period;
System.out.print("enter initial amount ");
balance = s.nextDouble();
System.out.print("enter rate as a decimal - e.g. .06 ");
rate = s.nextDouble();
System.out.print("enter division period ");
period = s.nextInt();
sum=balance*Math.pow(1+rate/period,period);
System.out.println("final sum:"+d.format(sum));
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote