Computer Science Homework Solutions
Problem
#21417

Help in flow control diagram, class diagram and design documentation

Please review documentation in the attached file. Please ensure that it displays flow control diagram, class diagram and design documentation for the JAVA code below. If needed please revise. Thank you


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();
        mCalc.setYears(30);
        mCalc.setLoanAmount(200000);
        mCalc.setInterestRate(.0575);
        mCalc.CalcMonthlyPayment();
        System.out.println(mCalc.toString());//Display the contents
        mCalc.schedule();
       }//end of group
}//closing bracket

mortgagecalculator.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.NumberFormatException;

/** 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:
* Divide the yearly interest rate of 5.75% by 12 to get monthly ineterst rate
* Multiply the number of years by 12 to get the number of months
* Formula for monthly payment: monthlyPayment = [P((1+r)^n)*r]/[(1+r^n)-1], where r and n are calculated as above.  
*
* 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
    {
        years=inYears;
    }//end set years
    
    public int getYears()//getter
    {
        return years;
    }//end get years
    
    public void setLoanAmount(double inLoanAmount)//setter
    {
        loanAmount=inLoanAmount;
    }//end set loanAmount
    
    public double getLoanAmount()//getter
    {
        return loanAmount;
    }//end get loanAmount
    
    public void setInterestRate(double inInterestRate)//setter
    {
        interestRate=inInterestRate;
    }//end set interestRate
    
    public double getInterestRate()//getter
    {
        return interestRate;
    }//end get interestrate
    
    public void CalcMonthlyPayment()
    {
        monthlyPayment=loanAmount*Math.pow(1 + interestRate/12, years*12) * (interestRate/12)/(Math.pow(1 + interestRate/12, years*12) -1);
    }//Divide the yearly interest rate of 5.75% by 12 to get monthly ineterst rate
     // Multiply the number of years by 12 to get the number of months
     // Formula for monthly payment: monthlyPayment = [P((1+r)^n)*r]/[(1+r^n)-1], where r and n are calculated as above.
        
    public String toString(){//strings are used to store text and variables
    return "Mortgage Information" + "n"+ "Loan Amount: $" + loanAmount + "n" + "Interest Rate: " + interestRate + "%" + "n" + "Term: "
    + (years*12) + " months" + "n" + "Monthly Payment: $" + (Math.round(monthlyPayment*100.00)/100.00);//Using the round to two decimal places
}      
    public void schedule(){//print schedule and scroll
        System.out.println();
        System.out.println("Month     " + "t" + "Amount     " + "tt" + "Interest    " + "t" + "Balance    ");
        int counter = 1;
        double Balance, Interest;
        while(counter <= years*12){
        int scrollCounter = 0;
        while(scrollCounter<30){
        Balance = loanAmount*(1+interestRate/12) - monthlyPayment; //Calculation of Balance
        Interest = loanAmount*interestRate/12; //Calculation of Interest
        //Now print using the round to two decimal places
        System.out.println(""+counter+"tt"+(Math.round(loanAmount*100.00)/100.00)+"tt"+(Math.round(Interest*100.00)/100.00)+"tt"+(Math.round(Balance*100.00)/100.00));
        loanAmount = Balance; //Set the Principal for next round to the Balance of previous month
        counter++;
        scrollCounter++;
        }
        System.out.println("Press Enter to contiune..");
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 1);
        String str = "";
        try {
        str = br.readLine();
        }
        catch (IOException ioe) {
        System.out.println(ioe);}
        }
    }//end group
}//closing bracket

Attached file(s):
Attachments
documentation.doc  View File

Attachment Content Summary (Note: view attachment at the above link before purchasing. Actual attachment content may vary slightly from that shown below.)

documentation.doc
Documentation and Flowchart

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, interest rate = 5.75%, monthly payment
= formula using math.pow. A list will be generated of loan balance and
interest paid for each payment over the term of the loan and scrolls on
the screen, hesitate and then display more of the list

Algorithm – Divide the yearly interest rate of 5.75% by 12 to get
monthly interest rate. Multiply the number of years by 12 to get the
number of months.

Formula for monthly payment: monthlyPayment =
[P((1+r)^n)*r]/[(1+r^n)-1], where r and n are calculated as above.

Java:

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

Inputs:

Principal = $200,000

Interest Rate = 0.0575

Periods = 360

Output:

Monthly Payment =



PAGE

PAGE 1
Solution
What is this?
By OTA - Overall OTA Rating
Marcia Wert, MS - 4.1/5
Purchase Cost Now
$2.19 CAD (was ~$27.93)
Included in Download
  • Plain text response
  • Attached file(s):
    • Drawing1.htm
    • Drawing1.jpg
$2.19 Instant Download
Add to Cart
Why you can trust BrainMass.com
  • Your Information is Secure
  • Best Online Academic Help Service
  • Students find real academic Success
Related Solutions
  • I keep getting errors when compiling this program in Java Netbeans Why? - 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 amo ...
  • Java - Change Request #2 Requestor: Dwain Hammer - Billings, MT Write the program in Java (without a graphical user interface) and have it calculate the payment amount for 3 mortgage loans: - 7 year at ...
  • Wrong output displayed in Java Program - My output display this: Mortgagecalculator@7ced01 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 ...
  • JAVA PROBLEM; - Please help in building a non GUI mortgage calculator that calculates and displays when executed in NETBEAN compiler: Principal = $200,000 Interest Rate = 0.0575 Periods = 360 Monthly Payment = Then s ...
  • C++ Programming - Please help me write the program as a procedural C++ program and using a loan amount of $200,000, a term of 30 years, and an interest rate of 5.75%. Insert comments in the program to document the prog ...
Browse