/*
PRG/420 Week 3 Assignment:  Mortgage Calculator Program
Programmer: Eva Manicom
Date:       March 1, 2010
Filename:   Mortgage Calculator Program
Purpose:    Modify the mortgage program to display the mortgage payment amount.  Then, list the loan balance and
            interest paid for each payment over the term of the loan.  The list would scroll off the screen, but
            use loops to display a partial list, hesitate, and then display more of the list.  Do not use a graphical
            user interface.  Insert comments in the program to document the program.
*/

//will format decimals for program
import java.text.DecimalFormat;

//Name of program: MortgageCalculatorProgram
public class MortgageCalculatorProgram
{
    public static void main(String[] arguments)
    {

  // define variables, payments, principle, interest, rate, and loan information

        double monthlyPayment;
        double principal;
        double interestRateYears;
        double interestRateMonths;
        int termYears;
        int termMonths;
        int linecount;

// will display balance, interest paid, principle, interest payments

        double balance;
        double interestPaid;
        double principalPaid;
        double monthlyInterestPayment;
        double monthlyPrincipalPayment;


// assign values to each item

        principal = 200000;
        interestRateYears = .0505;
        interestRateMonths = (interestRateYears / 12) / 100;
        termYears = 30;
        termMonths = (termYears * 12);
        monthlyInterestPayment = 0;
        monthlyPrincipalPayment = 0;
        balance = principal;

// display 10 lines of results at one time

        linecount = 10;

// will only display two decimal places out

        java.text.DecimalFormat dec = new java.text.DecimalFormat(",###.00");

// hard coded information per assignment

        System.out.println("\n\n\t*** Mortgage Calculator ***\n\n" +
                        "\nLoan Amount: \t$" + dec.format(principal) +
                        "\nInterest Rate: \t" + interestRateYears +"%" +
                        "\nTerm (Years): \t" + termYears);

// will calculate monthly mortgage payment

        monthlyPayment = (principal * interestRateMonths) /
                        (1 - Math.pow(1 + interestRateMonths, - termMonths));

// Print the information

        System.out.println("\n\nBased on the information, "  +
                        "the monthly payment amount will be: " +
                        "$" + dec.format(monthlyPayment));

// calculation

        monthlyInterestPayment = (balance * interestRateMonths);
        monthlyPrincipalPayment = (monthlyPayment - monthlyInterestPayment);

// provides columns

        System.out.println("\n\n\nMonths\t\tPrincipal\tInterest\tBalance");
        System.out.println("Remaining\tPayment\t\tPayment\t\tRemaining");
        System.out.println("---------  \t---------  \t---------  \t---------");

// start the while loop
       while (termMonths > 0)

{

// information to be displayed

       System.out.println(termMonths + "\t\t$" + dec.format(monthlyPrincipalPayment) +
                         "\t\t$" + dec.format(monthlyInterestPayment) +
                         "\t\t$" + dec.format(balance - monthlyPrincipalPayment));

// decrement of  months
       termMonths--;

// calculate interest and principal payments on the loan

       monthlyInterestPayment = (balance * interestRateMonths);
       monthlyPrincipalPayment = (monthlyPayment - monthlyInterestPayment);
       balance = (balance - monthlyPrincipalPayment);

// this will cause the results to pause
        if(linecount == 10)
        {

        linecount = 0;
        try
        {
        Thread.sleep(2000);

        }
        catch (InterruptedException e)
        {
          }
        }
// end if
        else
        {
        linecount++;
        }
// end else
        }
// end while
        }
// end main
}

************************************************

/*
PRG/420 Week 4 Assignment:  Mortgage Array Program
Programmer: Eva Manicom
Date:       March 8, 2010
Filename:   MortgageArray
Purpose:    Modify the mortgage program to display 3 mortgage loans:
            7 year at 5.25%, 15 year at 5.45 %, and 30 year at 5.05%.
            Use an array for the different loans (the array will be needed in the next course).
            Display the mortgage payment amount for each loan.  Do not use a graphical user interface.
            Insert comments in the program to document the program
*/


import java.io.*;  // java input output package
    import java.text.DecimalFormat;

class MortgageArray1

{

    public static void main(String[] arguments)

{

//starts the array
    double amount = 200000;
    int[]term = {7, 15, 30};
    double[] rate = {.0525, .0545, .0505};
    DecimalFormat twoDigits = new DecimalFormat("$000.00");

    System.out.println("With the loan amount of  " +twoDigits.format
    (amount));

    for (int i = 0; i < rate.length; i++)
    {

    System.out.print("for " + term[i] + " years");
    System.out.print("\tat a rate of " + rate[i]);
    double payment = (amount*(rate[i]/12))/(1-(Math.pow(1/(1+(rate
    [i]/12)),(term[i]*12))));

    System.out.println("\tThe monthly payment will be " +
    twoDigits.format(payment));

    }
  }
}

Follow the rules and post a question and show effort.

Sorry haven't done this before.
Here is what i need: Use an array for the different loans. Display the mortgage payment amount for each loan. Then, list the loan balance and interest paid for each payment over the term of the loan. Use loops to prevent lists from scrolling off the screen.

Can I combine them together? or start over?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.