Explore BrainMass

Explore BrainMass

    Wrong output displayed in Java Program

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    My output display this: [email protected]

    The output should display Years: 30, Loan Amount $200000.00, Interest Rate: .0575, and Monthly Payment: Calculated by Math.POW. Then a list of loan balance and interest paid for each payment over the term of the loan should scroll off the screen, but need loops to display a partial list, hesitate and then display more of the list. Do not use a graphical user interface. Please insert comments in the program so I can understand the fixes.

    The setter and getters must stay in MortgageCalculator.java and everything should output from main (Driver.java).


    import java.util.*;
    /***Created on June 27, 2004, 5:07 PM
    * Java Programming Project Workshop 3 -
    * Problem statement - Create a driver for the Mortgage Calculator
    * Scope - declare, initialize and set values and display mortgage calculator
    * @author TERRY PARKER
    public class Driver {

    * @param args the command line arguments
    public static void main(String args[]){//The main part of Mortgage Calculator begins here
    Mortgagecalculator mCalc;
    mCalc = new Mortgagecalculator();
    System.out.println(mCalc.toString());//Display the contents
    }//end of group
    }//closing bracket


    /** mortgagecalculator.java
    * Created on June 27, 2004, 5:07 PM
    * Java Programming Project Workshop 2 -
    * Problem statement - Create a Mortgage Calculator WITHOUT a graphical user interface
    * Purpose - provide a user-friendly service to potential users for accurately planning mortgage and other types of loans
    * Scope - The mortgage calculator must display the mortgage payment amount given the amount of the mortgage, the term of the mortgage, and the interest rate of the mortgage.
    * This program must have hard code amount = 200,000, term= 30 years, and the interest rate = 5.75% in class driver.java
    * Algorithm - standard loan calculation with fixed number of payments:
    * Monthly Payment = Principal * (InterestRate / (1 - (InterestRate + 1) - 12 * Periods)
    * Inputs:
    * Principal = $200,000
    * Interest Rate = 0.0575
    * Periods = 360
    * Output:
    * Monthly Payment =
    * @author TERRY PARKER
    * NETBEANS IDE 3.6*/

    public class Mortgagecalculator{

    /** Creates a static mortgagecalculator */

    public int years;//define variables
    public double loanAmount;
    public double interestRate;
    public double monthlyPayment;

    public void setYears(int inYears)//setter
    }//end set years

    public int getYears()//getter
    return years;
    }//end get years

    public void setLoanAmount(double inLoanAmount)//setter
    }//end set loanAmount

    public double getLoanAmount()//getter
    return loanAmount;
    }//end get loanAmount

    public void setInterestRate(double inInterestRate)//setter
    }//end set interestRate

    public double getInterestRate()//getter
    return interestRate;
    }//end get interestrate

    public void CalcMonthlyPayment()
    monthlyPayment=loanAmount*Math.pow(1 + interestRate, years) * interestRate/(Math.pow(1 + interestRate, years) -1);

    public String toString(double value){//strings are used to store text and variables
    String retString = new String();
    retString = "Values:";
    retString = retString + " years=" + years;
    retString = retString + " loanAmount=" + loanAmount;
    retString = retString + " interestRate=" + interestRate;
    retString = retString + " monthlyPayment=" + monthlyPayment;
    return retString;
    }//end group
    }//closing bracket

    © BrainMass Inc. brainmass.com February 24, 2021, 2:27 pm ad1c9bdddf

    Solution Summary

    The solution solves a java problem which has a wrong output displayed.