how do i modify this program so that it only displays the mortgage, principle, term and interest rate

Posted on 2005-04-17
Last Modified: 2010-03-31
how do i modify this program so that it only displays the mortgage, principle, term and interest rate
// Mortgage Rate Calculator
// Daniel Gallant
// Unversity of Phoenix - POS 406
// Dan McAllister
// Version 1.1.01 | 05/04/07 Due -> 05/13/05

//Version control sheet
//Version 1.1.1 find similar code and find erros in syntax
//Version 1.1.2 explain how code works
//Version 1.2.1 rename variables used in calculation
//Version 1.2.2 replace monthsMonthlyRate [1]and [0] with param[1]and [0] variable
//verison 1.2.3 replace again param with monthlyMonthlyRt
//Version 1.3.1 compile and enter extra notes

//program originally written by 'daily dream' an alias which can linked to
//program code retrieved on april 10th, 2005 at
// final editing done with help of Jim Cakalic 4-11-05 at

      //import the java classes
import java.text.NumberFormat;
import java.util.Locale;

public class MortgageMulti {
    //MortgageMulti is the existing function
    public static void main(String[] arguments) {

        //hard code the value of the mortgage
        double mortgage = 200000.00;
        //hard code in the yearly interst rate
        double[][] yearsYearlyRate = {
            { 7, 15, 30 },
            { 5.35, 5.5, 5.75 }
        //then code in the value for the number of times a year mulitplied by
        // the amoutn paid each time
        double[][] monthsMonthlyRt = {
            { yearsYearlyRate[0][0] * 12, yearsYearlyRate[0][1] * 12,
              yearsYearlyRate[0][2] * 12
            { yearsYearlyRate[1][0] / 1200, yearsYearlyRate[1][1] / 1200,
              yearsYearlyRate[1][2] / 1200

        for (int i = 0; i < 3; i++) {

            //Call the method
            double payment = calPayment(monthsMonthlyRt[1][i], monthsMonthlyRt[0][i], mortgage);

            // Display the monthly payment
            System.out.println("\nMortgage Amount \tTerm \t\tRate \t\tMonthly Payment");
            System.out.println("$200,000 \t\t" + yearsYearlyRate[0][i] + " years\t"
                    + yearsYearlyRate[1][i] + "%\t\t" + payment);

            System.out.println("\nMonth # \tInterest for the Month \t\tLoan Balance");

            // Call the method
            interestBalanceList(mortgage, monthsMonthlyRt[1][i], monthsMonthlyRt[0][i], payment);

    // Utility method to calculate the monthly mortgage payment
    // (1st error spotted)public static double calPayment(double param1, double
    // param2, double mortgage);
    public static double calPayment(double param1, double param2, double mortgage) {

        // Calculate the monthlyPayment of the mortgage
        double monthlyPayment = (param1 + param2 / (Math.pow((1 + param1), param2) - 1)) * mortgage;

        return monthlyPayment;

    // Utility method to list the interest paid and loan balance
    public static void interestBalanceList(double mortgage, double param1, double param2,
            double payment) {

        // Use the for loop to display the list
        for (int i = 1; i < (param2 + 1); i++) {

            // Pause the list and go to the next month and next amount
            System.out.println("Hit the 'ENTER' key to exit.");
            try {
            } catch (Exception e) {
            // Calculate the monthlyInterest
            double monthlyInterest = mortgage * param1;

            // Calculate the loanBlance
            double loanRemaining = mortgage - (payment - monthlyInterest);

            // Set the value of mortgageAmount to the value of loanRemaining
            mortgage = loanRemaining;

            // Formate the monthlyInterest into U.S. currency
            NumberFormat n = NumberFormat.getCurrencyInstance(Locale.US);
            String str = n.format(monthlyInterest);

            // Formate the loanRemaining into U.S. currency
            NumberFormat num = NumberFormat.getCurrencyInstance(Locale.US);
            String string = num.format(loanRemaining);

            // Display the month #, interest paid and loan balance
            System.out.println("\n " + i + "\t\t " + str + "\t\t\t" + string);

Question by:akaryu98
    LVL 30

    Accepted Solution


    Author Comment

    whatt does that mean by the link. i need it explained to me and show which prat of the code to remove to get the display. not just the link to another question!!!
    LVL 30

    Expert Comment

    Why did you accept that comment? It was a link to your own question. I meant that you should get this question deleted and your points refunded, because this was a duplicate of that one. You should ask one question only once :)

    Author Comment

    i am in a hurrry. andi would seem like an indian giver. you're right actually. but do you have an alternativ for this. i need to modif y this to show a mortgage scheddule for 30 years with 260 payments
    LVL 30

    Expert Comment

    Well, I don't have time to look into your code right. Since you've deleted the other question and accepted this one, you should request Community Support to re-open this question so that other experts can post on this.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
    Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
    Video by: Michael
    Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now