//Week2 Nicholas Zarnin

/*
Week 2: Mortgage Calculator
Programmer: Nicholas Zarnin
Date: June 11, 2006
Filename: Mortgage.java
Purpose: This program accepts input from a user for principal amount, term, and interest rate, and calculates the payment.   This program allows users to enter new information, or exit the program

*/

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

class Mortgage extends JFrame
  implements ActionListener {

  JButton Calculate;
  JButton Reset;
// What the text box is.
  JLabel loanLabel;
  JLabel interestLabel;
  JLabel yearsLabel;
  JLabel paymentLabel;

//Where user Inputs Data, and results too!
  JTextField loanTextbox;
  JTextField interestTextbox;
  JTextField yearsTextbox;
  JTextField paymentTextbox;
  JTextField paymentfield;

//Set the variables to 0, ready for input
  double amount=0;
  double years=0;
  double interest=0;
  double totalpayments=0;
  double monthly_interest_rate=0;
  double monthly_payment=0;
  double totalcalc=0;

//Currency Information for regional formatting
  NumberFormat curr = NumberFormat.getCurrencyInstance(Locale.US);

// This is where the form all comes together
  public Mortgage (int width, int height)
  {
    this.setTitle ("Nick's Mortgage Calculator");
    this.setResizable (true);
    this.setSize (400, 400);
    this.setLocationRelativeTo(null);
//This is how its going to close
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Container cPane = this.getContentPane();
    cPane.setLayout (new GridLayout(0,2));

    //The Calculate and reset botton
    Calculate = new JButton ("Calculate");
    Calculate.addActionListener (this);
    cPane.add (Calculate);

    Reset = new JButton("Reset");
Reset.addActionListener (this);
cPane.add (Reset);

//This is where I declare the Fields and the Labels for the GUI
    loanLabel = new JLabel ("Loan... [continues]

Read full essay

Cite This Essay

APA

(2006, 06). Pos 407 Week 2. StudyMode.com. Retrieved 06, 2006, from http://www.studymode.com/essays/Pos-407-Week-2-91424.html

MLA

"Pos 407 Week 2" StudyMode.com. 06 2006. 06 2006 <http://www.studymode.com/essays/Pos-407-Week-2-91424.html>.

CHICAGO

"Pos 407 Week 2." StudyMode.com. 06, 2006. Accessed 06, 2006. http://www.studymode.com/essays/Pos-407-Week-2-91424.html.