We help IT Professionals succeed at work.

subtract the payment from the balance

dhalecbh
dhalecbh asked
on
727 Views
Last Modified: 2013-11-23
subtract the payment from the balanceP = (i * Principle x (1 + i)^n) / ((1 + i)^n - 1), where would this go in the code.  

.calculate the interest from the current balance*
 add it to the balance
 subtract the payment from the balance
 this is the new balance
 repeat 360 times (total number of payments over a 30 year period)




/*
      Week 2:            Service request SR-mf-003
      Programmer:      Diane Hale
      Filename:      NewClassWeek2.java
      Purpose:      This program will calculates the monthly payment of a $200,000
                   loan at 5.75% over 30 years.
*/

import java.io.*;
public class NewClassWeek2
{
      public static void main(String[] args)
      {
            // declare and construct variables
            int term = 30, months = term * 12, LoanAmount = 200000;
            double IntRate = 5.75, Payment, I = IntRate / 1200;

            // print prompts and get input
            System.out.println("This program will calculate the mortgage payment to fully amortized");
            System.out.println("a $200,000 loan over 30 years at 5.75%");
            System.out.println();

            // calculations
            Payment = Math.round(LoanAmount / ((1 - Math.pow((1 + I), -months)) / I) *100);
            Payment = Payment / 100;

            //output
            System.out.println("The load payment on a $" + LoanAmount + " mortgage over " + term + " years at " + IntRate + "% is:");
            System.out.println("$" + Payment);
            System.out.println();
      }

}
Comment
Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
If this is a course assignment, I would very humbly suggest you try (much) harder to solve the question yourself, without any outside help. Programming is all about solving problems, and being really stubborn about WANTING to solve them yourself. Programming routine throws several problems at you every working day.. so, as a programming student, you really need to cultivate the attitude of trying to solve the problems yourself first.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.