Financial Application

Page 1 of 1

2 Replies - 20958 Views - Last Post: 23 October 2010 - 05:04 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=196403&amp;s=8a8483993405c29137324dd75efa274f&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

#1 Uushie

• New D.I.C Head

Reputation: 2
• Posts: 27
• Joined: 23-October 10

Financial Application

Posted 23 October 2010 - 11:31 AM

Hey everyone, I am trying to get this program to work but I think I have an error in my math. After countless tries, I have become frustrated.

I want to write a method that computes a future investment value after the user inputs the amount of the investment and the monthly interest rate after that, it will display the next 30 years of interest on the investment.

An example of the output after you put in the input,

The amount invested: 1000
Annual interest rate: 9%
Years Future Value
1 1093.80
2 1196.41
...
29 13467.25
30 14730.57

I'm almost positive that my math is off when it comes to this part

```    double Month = ((monthlyInterestRate / 12));
double YearlyInterest = investmentAmount * Month / (1 / Math.pow(1 + Month, i));
return (investmentAmount + YearlyInterest);

```

However, I could be wrong. Anyways, if you can help me with my math as I keep trying to figure out the formula but come up short. Thanks for your help!

``` import java.util.Scanner;
public class Exercise05_07 {
static Scanner input = new Scanner(System.in);
public static void main(String[] args) {
System.out.print("Enter investment amount: ");
double investmentAmount = input.nextDouble();
System.out.print("Enter annual interest rate amount: ");
double monthlyInterestRate = input.nextDouble();

System.out.println("The amount invested: " + investmentAmount);
System.out.println("Annual interest rate: " + monthlyInterestRate + "%");
System.out.println("Years       Future Value");
for (int i = 1; i < 31; i++) {
System.out.println(i + "              " + futureInvestmentValue(
investmentAmount, monthlyInterestRate, i));
}
}

public static double futureInvestmentValue(double investmentAmount,
double monthlyInterestRate, int i) {
double Month = ((monthlyInterestRate / 12));
double YearlyInterest = investmentAmount * Month / (1 / Math.pow(1 + Month, i));
return (investmentAmount + YearlyInterest);
}
}

```

Is This A Good Question/Topic? 0

Replies To: Financial Application

#2 H3R3T1C

• Android Expert

Reputation: 278
• Posts: 757
• Joined: 30-March 07

Re: Financial Application

Posted 23 October 2010 - 01:13 PM

Ok so is the interest supposed to be compounded every month or just every year?

#3 Uushie

• New D.I.C Head

Reputation: 2
• Posts: 27
• Joined: 23-October 10

Re: Financial Application

Posted 23 October 2010 - 05:04 PM

Alright I just realized how stupid I am and made careless mistakes.

1. It was supposed to be yearly interest all along in the input, I was under the assumption that it was supposed to be monthly input silly me.

Anyways, here is the finished code if anyone is curious and wants to check it out.

Thanks for responding, I appreciate it, after hours of going insane, I finally got the right answer and as I thought, it was because I made a silly careless mistake!

```import java.util.Scanner;

public class Exercise05_07 {

static Scanner input = new Scanner(System.in);

public static void main(String[] args) {
System.out.print("Enter investment amount: ");
double investmentAmount = input.nextDouble();
System.out.print("Enter Yearly interest rate amount: ");
double yearlyInterestRate = input.nextDouble();
double monthlyInterestRate = ((yearlyInterestRate / 1200));

System.out.println("The amount invested: " + investmentAmount);
System.out.println("Annual interest rate: " + yearlyInterestRate + "%");
System.out.println("Years       Future Value");
for (int i = 1; i < 31; i++) {
System.out.println(i + "              " + futureInvestmentValue(
investmentAmount, monthlyInterestRate, i));
}
}

public static double futureInvestmentValue(double investmentAmount,
double monthlyInterestRate, int i) {

double YearlyInterest = (investmentAmount * (Math.pow(1 +
monthlyInterestRate, i * 12)));
return (YearlyInterest);
}
}

```