mortgage calculator with GUI

Posted on 2005-05-15
Last Modified: 2010-03-31
how can i modify this code so that i can be within a graphical user interface, must have user input for amount of mortgage. and Allow the user to loop back and enter new data or quit.

//Version 1.1.1 find similar code
//Version 1.2.1 remove unneeded code from program
//Version 1.2.2 rename variables
//Version 1.3.1 explain how the code works in the notes
//Version 1.3.1 compile and enter extra notes

import java.lang.Math;               //Import math class to do the calculations
import java.text.DecimalFormat;     //Import decimal formatting class which will format the numbers

 class MortgageMulti2 { //Declare Class, which is also the filename
     public static void main(String[] arguments) {
          double interest = .0575;  //Interest rate in decimal format
          double amount = 200000;  // the principle amount borrowed
          double payments = 360;     //Term of loan in months, basically the unmber of payments made over 30 years
          double monthlyPymnt = (interest/12);     //Monthly interest rate = 5.75% multiplied by twelve

          //By typing 'prinln' i can show my name, my class namne, and the basic output required
          //which includes Principal amount, interest rate, and number of payments
          System.out.println("Name:         Daniel Gallant");
          System.out.println("Assignment:   Week 2 program");
          System.out.println("________________________ \n");
          //this tells the program to skip a line
          System.out.println("Principle       : $" + amount);
          //this reads the principle amount and then displays it
          System.out.println("Interest Rate   : " + interest * 100 + "%");
          //this calculates the interest rate and puts it in percentage form
          System.out.println("# of Payments   : " + payments);
          //theis read the payments variable and displays the number of payments

          /*This is the original mortgae paymetn formaula which is used to finance the loan itself :
          Payments * interest / ( 1 - (1 + interest)^ -number of payments )*/

          double payment = (amount * monthlyPymnt) /  (1- Math.pow((1 + monthlyPymnt), -payments));
          //this defines the decimal format used in the interest rate, principle, and the monthly payments
          DecimalFormat myVar = new DecimalFormat("$###,##0.00");
          String myoutput = myVar.format(payments);
          System.out.println("Monthly Payment : " + myoutput + "\n");
          // this reads and displays 'monthly payment" and the value of the variable monthly payment after it's calculated
//program originally written by 'Tom Pitts' he can linked to
//program code retrieved on april 10th, 2005 at
// final editing done with help of Sudhakar Koundinya 9-14-2004 at
Question by:akaryu98
    LVL 16

    Accepted Solution


    I think that you need to delete this question as it is the same as previous one unless you need additional explanation or answer. My question is do you have additional question? Or do you need more information? Since you gave me a grade of C in the previous post, I assume that you are not fully satisfied on what you want.

    LVL 16

    Expert Comment


    I do really think that you should refund your point for this question instead of awarding the point to me


    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!

    Join & Write a Comment

    Suggested Solutions

    An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
    Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
    This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
    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 …

    754 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

    20 Experts available now in Live!

    Get 1:1 Help Now