Purchase Solution

Mortgage calculator (with a graphical user interface) in Java

Not what you're looking for?

Ask Custom Question

Write a program in Java (with a graphical user interface) that calculates and displays the mortgage payment amount, based on the user input of the mortgage amount and the user's selection from a menu of available mortgage loans (as given below).

- 7 years at 5.35%
- 15 years at 5.5%
- 30 years at 5.75%

Use an array for the mortgage data for the different loans. Display the mortgage payment amount followed by the loan balance and interest paid for each payment over the term of the loan. Allow the user to enter a new amount and make a new selection or quit. Please insert comments in the program to document the program for easy understanding.

Purchase this Solution

Solution Summary

This solution builds a mortgage calculator for the student. Comments in the program are simple and will help guide the student through what this code is doing so they are able to apply this learning to other projects.

Solution Preview

Please see the attachment.

// MortgageWithGUI.java

import java.io.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.*;
import java.util.*;

public class MortgageWithGUI extends JFrame
{
private String[] terms={"7","15","30"}; // terms array
private double[] rates={.0535,0.055,0.0575}; // interest array

// Declare components for window
private JLabel amountLabel=new JLabel("Loan amount: ");
private JTextField amount=new JTextField();
private JLabel termLabel=new JLabel("Term: ");
private JTextField term=new JTextField();
private JLabel rateLabel=new JLabel("Interest rate: ");
private JTextField rate=new JTextField();
private JLabel payLabel=new JLabel("Monthly Payment: ");
private JLabel payment=new JLabel();
private JButton calculate=new JButton("Calculate");
private JButton clear=new JButton("Clear");
private JButton exit=new JButton("Exit");
private JTextArea paymentSchedule=new JTextArea();
private JScrollPane schedulePane=new JScrollPane(paymentSchedule);
private Container cp = getContentPane();

public MortgageWithGUI(String title)
{

super.setTitle(title); // set title of windows

// Create three radio buttons

JRadioButton first = new JRadioButton("7 @ 5.35%");
JRadioButton second = new JRadioButton("15 @ 5.5%");
JRadioButton third = new JRadioButton("30 @ 5.75%");

// create panel for radio buttons
JPanel panel = new ...

Purchase this Solution


Free BrainMass Quizzes
Basic Networking Questions

This quiz consists of some basic networking questions.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.