I am having a hard time applying this to my java program.
Main Topics
Browse All TopicsI am trying to figure out agood formula for calculating MonthlyPayment, MonthlyInterestPaid, and Balance.
import java.text.DecimalFormat; //Required for format output
public class MortgagePaymentCalculator
{
//Hard code the amount=400,000, the term=30 years, and the interest rate=4.75%
static double MortgageAmount = 400000;
//400,000 is the amount of the mortgage
static int TermYears = 30;
//30 is the length of time that the amount is to be payed back
static double InterestRate = 4.75;
//4.75 is the percentage of interest to be paid monthly
static double MonthlyPayment;
//Total monthly payment
static double MonthlyInterest;
static int Months;
static double MonthlyInterestRate;
static int Payment;
static double Balance;
static double MonthlyInterestPaid;
//Main
public static void main(String[] args)
{
//Monthly Payment Calculations
Months = (TermYears * 12);
//Calculates the total number of months to pay mortgage (360)
MonthlyInterestRate = (InterestRate *.01);
//Calculates the rate to a decimal format
MonthlyInterest = (MonthlyInterestRate/12);
//Calculates the amount of monthly interest
//Calculates monthly payment
MonthlyPayment =
//Calculates the monthly payment
MonthlyInterestPaid =
//Calculates the monthly interest paid
Balance =
//Monthly Mortgage Payment Calculator Heading
DecimalFormat Money = new DecimalFormat("$0,000.00")
System.out.println("//////
System.out.println(" Monthly Mortgage Payment Calculator");
System.out.println("//////
System.out.println("------
System.out.println();
//data produced from calculations
System.out.println("Total Mortgage Financed: "+ Money.format(MortgageAmoun
System.out.println();
System.out.println("Total Mortgage Term: "+ TermYears);
System.out.println();
System.out.println("Intere
System.out.println();
System.out.println("Monthl
System.out.println("------
System.out.println();
//requesting the payment amount to be calculated
System.out.println("Paymen
System.out.println();
System.out.println("Paymen
System.out.println("Intere
System.out.println("Loan Balance: " + Money.format(Balance));
System.out.println();
System.out.println("------
System.out.println();
}//End Payment Calculations
}//End MortgagePaymentCalulator
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Good on the monthly payment as far as I can see.
Don't make the other two more complicated.
Interest payment is simply monthly interest rate times balance, correct? So think you had what you needed for that all along.
Then new balance is current balance less what you just calculated for monthly payment.
Regards,
mwvisa1
Business Accounts
Answer for Membership
by: mwvisa1Posted on 2009-10-31 at 20:29:16ID: 25712510
major75,
interest.h tm
Ref. http://www.fonerbooks.com/
The above will explain to you this formula :
M = P [ i(1 + i)n ] / [ (1 + i)n - 1]
Where M is the mortgage payment; P is principle; i is interest rate; n is the number of monthly payments.
Try to apply it in Java and post back if you need additional assistance.