Hi all,
I have to write a program that uses this equation:
Untitled1.png
when you type in the numbers 7500, 14.5, and 36 you should get:
The amount I wish to borrow is? 7500
The loan rate I can get is? 14.5
The number of months it will take me to pay off the loan is? 36
Why doesnt it work? Heres the code:
import java.io.*;
import java.util.*;
public class Prog58i
{
public static void main (String[] args)
{
//input
System.out.print("the amount I wish to borrow is? ");
Scanner a = new Scanner(System.in);
double borrow = a.nextDouble(); //P
System.out.print("The loan rate I can get is? ");
Scanner b = new Scanner(System.in);
double rate = b.nextDouble(); //R
System.out.print("The number of months it will take me to pay of this loan is? ");
Scanner c = new Scanner(System.in);
double months = c.nextDouble(); //M
//Processing
double MP = borrow * (rate/1200) * Math.pow((1+rate/1200), months) / (Math.pow((1+rate/1200), months)- 1);
double intrest = (MP * months) - borrow;
double repaid = (MP*months);
//Output
System.out.print( "My monthly payments will be $" +MP +"\n");
System.out.print( "Total Interest Paid is $" +intrest +"\n");
System.out.print( "Total Amount Paid is $" +repaid +"\n");
Im very new to Java so please make the answers as simple as possible. Thanks