Mortgage Program in GUI format

I am having trouble with writing a mortgage program. The program should allow the users to choose the format inwhich they input their mortgage information. It is to then display his mortgage payment, monthly interest, and balance over the duration of the loan. I thought I had everything right, after serveral error corrections, I get the below listed errors. I understand what they are saying is wrong with the program, but I lack the ability ot decipher how to fix it. Any informaton would be greatly appreciated.
errors:
H:\My Documents\Java Training\ShellyJava\Chapter.10\week4.java:333: illegal start of expression
private static void createAndShowGUI() {
^
H:\My Documents\Java Training\ShellyJava\Chapter.10\week4.java:388: ';' expected
^
2 errors
Code;
import java.util.Set;
import java.util.HashSet;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;
import java.text.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JLabel;
import java.awt.Container;
import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.Graphics.*;
import java.lang.Math.*;
import java.util.*;
import java.text.NumberFormat;
import java.io.*;
import java.awt.event.*;
import javax.swing.*;
public class week4 extends JPanel {
//Defines Labels
private JLabel Amount_Label;
private JLabel Rate_Label;
private JLabel Term_Label;
private JLabel Payments_Label;
//Defines Strings for Labels
private static String Amount_String = "Loan Amount: ";
private static String Rate_String = "Percentage Rate: ";
private static String Term_String = "Term (In Years): ";
private static String Payments_String = "Monthly Payment: ";
//Defines Text Fields
private JTextField Amount_Field;
private JTextField Rate_Field;
private JTextField Term_Field;
private JTextField Payments_Field;
//Defines number Formats
private NumberFormat Loan_Format;
private NumberFormat Rate_Format;
private DecimalFormat Term_Format;
private DecimalFormat Payments_Format;
private Verifier verifier = new Verifier();
//Defines Buttons
private JButton MortgageCalc = new JButton("Calculate");
     private JButton Clear = new JButton("Clear");
     private JButton Exit = new JButton("Good-bye");
     //Defines Combo Boxes
     private JComboBox Rate_Box;
     private JComboBox Term_Box;
public week4() {
super(new BorderLayout());
setUpFormats();
//Creates the labels.
Amount_Label = new JLabel(Amount_String);
Rate_Label = new JLabel(Rate_String);
Term_Label = new JLabel(Term_String);
Payments_Label = new JLabel(Payments_String);
//Creates the text fields
Amount_Field = new JTextField(Loan_Format.format(0), 12);
Amount_Field.setInputVerifier(verifier);
Rate_Field = new JTextField(Rate_Format.format(0), 12);
Rate_Field.setInputVerifier(verifier);
Term_Field = new JTextField(Term_Format.format(0), 12);
Term_Field.setInputVerifier(verifier);
Payments_Field = new JTextField(Payments_Format.format(0), 12);
Payments_Field.setInputVerifier(verifier);
Payments_Field.setEditable(false);
//Creates Buttons
MortgageCalc = new JButton("Calculate");
Clear = new JButton("Clear");
Exit = new JButton("Exit");
//Creates the Combo Boxes
Rate_Box = new JComboBox ();
     Rate_Box.addItem("5.35%");
     Rate_Box.addItem("5.50%");
     Rate_Box.addItem("5.75%");
     Rate_Box.addItem("Select One");
     add(Rate_Box);
Term_Box = new JComboBox ();
     Term_box.addItem("7 years");
     Term_box.addItem("15 years");
     Term_box.addItem("30 years");
     Term_box.addItem("Select One");
     add(Term_Box);
//Defines Listner
Amount_Field.addActionListener(verifier);
Rate_Field.addActionListener(verifier);
Term_Field.addActionListener(verifier);
Rate_Box.addActionListener(verifier);
Term_box.addActionListener(verifier);
MortgageCalc.addActionListener(verifier);
Clear.addActionListner(verifier);
Exit.addActionListener(verifier);
//Sets Labels
Amount_Label.setLabelFor(Amount_Field);
Rate_Label.setLabelFor(Rate_Box);
Term_Label.setLabelFor(Term_Box);
Payments_Label.setLabelFor(Payments_Field);
//Layout setup
JPanel labelPane = new JPanel(new GridLayout(0,1));
labelPane.add(Amount_Label);
labelPane.add(Rate_Label);
labelPane.add(Term_Label);
labelPane.add(Payments_Label);
JPanel fieldPane = new JPanel(new GridLayout(0,1));
fieldPane.add(Amount_Field);
fieldPane.add(Rate_Box);
fieldPane.add(Term_Box);
fieldPane.add(Payments_Field);
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.CENTER));
buttonPane.add(MortgageCalc);
buttonPane.add(Clear);
     buttonPane.add(Exit);
setBorder(BorderFactory.createEmptyBorder(25, 25, 25, 25));
add(labelPane, BorderLayout.CENTER);
add(fieldPane, BorderLayout.LINE_END);
add(buttonPane, BorderLayout.SOUTH);
class Verifier extends InputVerifier
implements ActionListener {
double MIN_AMOUNT = 100;
double MAX_AMOUNT = 9999999;
double MIN_RATE = 0.0;
int MIN_PERIOD = 1;
int MAX_PERIOD = 30;
public boolean shouldYieldFocus(JComponent input) {
boolean inputOK = verify(input);
updatePayment();
if (inputOK) {
return true;
} else {
Toolkit.getDefaultToolkit().beep();
return false;
protected void updatePayment() {
double amount = 0;
double rate = 0.0;
int termPeriods = 0;
double payment = 0.0;
//Parse numbers
try {
amount = Loan_Format.parse(Amount_Field.getText()).
doubleValue();
} catch (ParseException pe) {}
try {
rate = Rate_Format.parse(Rate_Field.getText()).
doubleValue();
} catch (ParseException pe) {}
try {
termPeriods = Term_Format.parse(Term_Field.getText()).
intValue();
} catch (ParseException pe) {}
//Calculate
payment = computePayment(amount, rate, termPeriods);
Payments_Field.setText(Payments_Format.format(payment));
public boolean verify(JComponent input) {
return checkField(input, false);
protected boolean checkField(JComponent input, boolean changeIt) {
if (input == Amount_Field) {
return checkAmount_Field(changeIt);
} else if (input == Rate_Field) {
return checkRate_Field(changeIt);
} else if (input == Term_Field) {
return checkTerm_Field(changeIt);
} else {
return true;
protected boolean checkAmount_Field(boolean change) {
boolean wasValid = true;
double amount = 0;
try {
amount = Loan_Format.parse(Amount_Field.getText()).
doubleValue();
} catch (ParseException pe) {
wasValid = false;
if ((amount < MIN_AMOUNT) || (amount > MAX_AMOUNT)) {
wasValid = false;
if (change) {
if (amount < MIN_AMOUNT) {
amount = MIN_AMOUNT;
} else {
amount = MAX_AMOUNT;
if (change) {
Amount_Field.setText(Loan_Format.format(amount));
Amount_Field.selectAll();
return wasValid;
protected boolean checkRate_Field(boolean change) {
boolean wasValid = true;
double rate = 0;
try {
rate = Rate_Format.parse(Rate_Field.getText()).
doubleValue();
} catch (ParseException pe) {
wasValid = false;
if (rate < MIN_RATE) {
wasValid = false;
if (change) {
rate = MIN_RATE;
if (change) {
Rate_Field.setText(Rate_Format.format(rate));
Rate_Field.selectAll();
return wasValid;
protected boolean checkTerm_Field(boolean change) {
boolean wasValid = true;
int termPeriods = 0;
try {
termPeriods = Term_Format.parse(Term_Field.getText()).
intValue();
} catch (ParseException pe) {
wasValid = false;
if ((termPeriods < MIN_PERIOD) || (termPeriods > MAX_PERIOD)) {
wasValid = false;
if (change) {
if (termPeriods < MIN_PERIOD) {
termPeriods = MIN_PERIOD;
} else {
termPeriods = MAX_PERIOD;
if (change) {
Term_Field.setText(Term_Format.format(termPeriods));
Term_Field.selectAll();
return wasValid;
public void actionPerformed(ActionEvent e) {
JTextField source = (JTextField)e.getSource();
shouldYieldFocus(source);
source.selectAll();
private static void createAndShowGUI() {
     JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("Week 4 Assignment - Bonnita Ludwig");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JComponent newContentPane = new week4();
newContentPane.setOpaque(true);
frame.setContentPane(newContentPane);
frame.pack();
frame.setVisible(true);
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
double computePayment(double loanAmt, double rate, int termPeriods) {
double I, partial1, denominator, answer;
termPeriods *= 12;
if (rate > 0.01) {
I = rate / 100.0 / 12.0;
partial1 = Math.pow((1 + I), (0.0 - termPeriods));
denominator = (1 - partial1) / I;
} else {
denominator = termPeriods;
answer = (-1 * loanAmt) / denominator;
return answer;
private void setUpFormats() {
Loan_Format = (NumberFormat)NumberFormat.getNumberInstance();
Rate_Format = NumberFormat.getNumberInstance();
Rate_Format.setMinimumFractionDigits(3);
Term_Format = (DecimalFormat)NumberFormat.getNumberInstance();
Term_Format.setParseIntegerOnly(true);
Payments_Format = (DecimalFormat)NumberFormat.getNumberInstance();
Payments_Format.setMaximumFractionDigits(2);
Payments_Format.setNegativePrefix("(");
Payments_Format.setNegativeSuffix(")");
/* References:
*http://java.sun.com/docs/books/tutorial/uiswing/misc/example-1dot4/index.html#InputVerificationDemo
*http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html
*/

Thanks for the direction, but I am still getting this error:
week4.java:377: illegal start of expression
public actionPerformed(ActionEvent e)
^
1 error
I see that I have to work on my ability to decipher code. I am very new Java and really appreciate your assistance. I have included my code after making the several changes.
Code:
import java.util.Set;
import java.util.HashSet;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;
import java.text.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JLabel;
import java.awt.Container;
import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.Graphics.*;
import java.lang.Math.*;
import java.util.*;
import java.text.NumberFormat;
import java.io.*;
import java.awt.event.*;
import javax.swing.*;
public class week4 extends JPanel
//Defines Labels
private JLabel Amount_Label;
private JLabel Rate_Label;
private JLabel Term_Label;
private JLabel Payments_Label;
//Defines Strings for Labels
private static String Amount_String = "Loan Amount: ";
private static String Rate_String = "Percentage Rate: ";
private static String Term_String = "Term (In Years): ";
private static String Payments_String = "Monthly Payment: ";
//Defines Text Fields
private JTextField Amount_Field;
private JTextField Rate_Field;
private JTextField Term_Field;
private JTextField Payments_Field;
//Defines number Formats
private NumberFormat Loan_Format;
private NumberFormat Rate_Format;
private DecimalFormat Term_Format;
private DecimalFormat Payments_Format;
private Verifier verifier = new Verifier();
//Defines Buttons
private JButton MortgageCalc = new JButton("Calculate");
     private JButton Clear = new JButton("Clear");
     private JButton Exit = new JButton("Good-bye");
     //Defines Combo Boxes
     private JComboBox Rate_Box;
     private JComboBox Term_Box;
public week4()
super(new BorderLayout());
setUpFormats();
//Creates the labels.
Amount_Label = new JLabel(Amount_String);
Rate_Label = new JLabel(Rate_String);
Term_Label = new JLabel(Term_String);
Payments_Label = new JLabel(Payments_String);
//Creates the text fields
Amount_Field = new JTextField(Loan_Format.format(0), 12);
Amount_Field.setInputVerifier(verifier);
Rate_Field = new JTextField(Rate_Format.format(0), 12);
Rate_Field.setInputVerifier(verifier);
Term_Field = new JTextField(Term_Format.format(0), 12);
Term_Field.setInputVerifier(verifier);
Payments_Field = new JTextField(Payments_Format.format(0), 12);
Payments_Field.setInputVerifier(verifier);
Payments_Field.setEditable(false);
//Creates Buttons
MortgageCalc = new JButton("Calculate");
Clear = new JButton("Clear");
Exit = new JButton("Exit");
//Creates the Combo Boxes
Rate_Box = new JComboBox ();
     Rate_Box.addItem("5.35%");
     Rate_Box.addItem("5.50%");
     Rate_Box.addItem("5.75%");
     Rate_Box.addItem("Select One");
     add(Rate_Box);
Term_Box = new JComboBox ();
     Term_box.addItem("7 years");
     Term_box.addItem("15 years");
     Term_box.addItem("30 years");
     Term_box.addItem("Select One");
     add(Term_Box);
//Defines Listner
Amount_Field.addActionListener(verifier);
Rate_Field.addActionListener(verifier);
Term_Field.addActionListener(verifier);
Rate_Box.addActionListener(verifier);
Term_box.addActionListener(verifier);
MortgageCalc.addActionListener(verifier);
Clear.addActionListner(verifier);
Exit.addActionListener(verifier);
//Sets Labels
Amount_Label.setLabelFor(Amount_Field);
Rate_Label.setLabelFor(Rate_Box);
Term_Label.setLabelFor(Term_Box);
Payments_Label.setLabelFor(Payments_Field);
//Layout setup
JPanel labelPane = new JPanel(new GridLayout(0,1));
labelPane.add(Amount_Label);
labelPane.add(Rate_Label);
labelPane.add(Term_Label);
labelPane.add(Payments_Label);
JPanel fieldPane = new JPanel(new GridLayout(0,1));
fieldPane.add(Amount_Field);
fieldPane.add(Rate_Box);
fieldPane.add(Term_Box);
fieldPane.add(Payments_Field);
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.CENTER));
buttonPane.add(MortgageCalc);
buttonPane.add(Clear);
     buttonPane.add(Exit);
setBorder(BorderFactory.createEmptyBorder(25, 25, 25, 25));
add(labelPane, BorderLayout.CENTER);
add(fieldPane, BorderLayout.LINE_END);
add(buttonPane, BorderLayout.SOUTH);
     class Verifier extends InputVerifier implements ActionListener
     double MIN_AMOUNT = 100;
     double MAX_AMOUNT = 9999999;
     double MIN_RATE = 0.0;
     int MIN_PERIOD = 1;
     int MAX_PERIOD = 30;
          public boolean shouldYieldFocus(JComponent input)
     boolean inputOK = verify(input);
     updatePayment();
     if (inputOK)
     return true;
     else
     Toolkit.getDefaultToolkit().beep();
     return false;
     protected void updatePayment()
     double amount = 0;
     double rate = 0.0;
     int termPeriods = 0;
     double payment = 0.0;
     //Parse numbers
     try
     amount = Loan_Format.parse(Amount_Field.getText()).
doubleValue();
     catch (ParseException pe)
     try
rate = Rate_Format.parse(Rate_Field.getText()).
doubleValue();
     catch (ParseException pe)
     try
termPeriods = Term_Format.parse(Term_Field.getText()).
intValue();
     catch (ParseException pe)
     //Calculate
     payment = computePayment(amount, rate, termPeriods);
     Payments_Field.setText(Payments_Format.format(payment));
public boolean verify(JComponent input)
return checkField(input, false);
protected boolean checkField(JComponent input, boolean changeIt)
if (input == Amount_Field)
return checkAmount_Field(changeIt);
else if (input == Rate_Field)
return checkRate_Field(changeIt);
else if (input == Term_Field)
return checkTerm_Field(changeIt);
else
return true;
protected boolean checkAmount_Field(boolean change)
boolean wasValid = true;
double amount = 0;
try
amount = Loan_Format.parse(Amount_Field.getText()).
doubleValue();
catch (ParseException pe)
wasValid = false;
if ((amount < MIN_AMOUNT) || (amount > MAX_AMOUNT))
wasValid = false;
if (change)
if (amount < MIN_AMOUNT)
amount = MIN_AMOUNT;
else
amount = MAX_AMOUNT;
if (change)
Amount_Field.setText(Loan_Format.format(amount));
Amount_Field.selectAll();
return wasValid;
protected boolean checkRate_Field(boolean change)
boolean wasValid = true;
double rate = 0;
try
rate = Rate_Format.parse(Rate_Field.getText()).
doubleValue();
catch (ParseException pe)
wasValid = false;
if (rate < MIN_RATE)
wasValid = false;
if (change)
rate = MIN_RATE;
if (change)
Rate_Field.setText(Rate_Format.format(rate));
Rate_Field.selectAll();
return wasValid;
protected boolean checkTerm_Field(boolean change)
boolean wasValid = true;
int termPeriods = 0;
try
termPeriods = Term_Format.parse(Term_Field.getText()).
intValue();
catch (ParseException pe)
wasValid = false;
if ((termPeriods < MIN_PERIOD) || (termPeriods > MAX_PERIOD))
wasValid = false;
if (change)
if (termPeriods < MIN_PERIOD)
termPeriods = MIN_PERIOD;
else
termPeriods = MAX_PERIOD;
if (change)
Term_Field.setText(Term_Format.format(termPeriods));
Term_Field.selectAll();
return wasValid;
public actionPerformed(ActionEvent e)
JTextField source = (JTextField)e.getSource();
shouldYieldFocus(source);
source.selectAll();
     public createAndShowGUI()
          JFrame.setDefaultLookAndFeelDecorated(true);
     JFrame frame = new JFrame("Week 4 Assignment - Bonnita Ludwig");
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     JComponent newContentPane = new week4();
     newContentPane.setOpaque(true);
     frame.setContentPane(newContentPane);
     frame.pack();
     frame.setVisible(true);
     public static void main(String[] args)
     javax.swing.SwingUtilities.invokeLater(new Runnable()
     public void run()
     createAndShowGUI();
     double computePayment(double loanAmt, double rate, int termPeriods)
     double I, partial1, denominator, answer;
     termPeriods *= 12;
     if (rate > 0.01)
     I = rate / 100.0 / 12.0;
     partial1 = Math.pow((1 + I), (0.0 - termPeriods));
     denominator = (1 - partial1) / I;
     else
     denominator = termPeriods;
     answer = (-1 * loanAmt) / denominator;
          return answer;
     private void setUpFormats()
     Loan_Format = (NumberFormat)NumberFormat.getNumberInstance();
     Rate_Format = NumberFormat.getNumberInstance();
     Rate_Format.setMinimumFractionDigits(3);
     Term_Format = (DecimalFormat)NumberFormat.getNumberInstance();
     Term_Format.setParseIntegerOnly(true);
     Payments_Format = (DecimalFormat)NumberFormat.getNumberInstance();
     Payments_Format.setMaximumFractionDigits(2);
     Payments_Format.setNegativePrefix("(");
     Payments_Format.setNegativeSuffix(")");
}

Similar Messages

  • Mortgage Program Question

    Hello all, I am having issues with my program, I did ask a question before apparently I was told that I was not cleared, so I'm going to try to explain my problem the best that I can. I have to create a mortgage calculator with GUI that would allow user's to input a Loan amount, select from the menu. What I'm confused is that when I input an amount and select, from the menu then press the calculate button, the monthly payment and the values in my textarea is giving me a worng answer. It looks to me that the formula is calculating my term array values as the rate, and my rate array as the term, and it's giving a huge amount of payment. Can anyone hint me on waht I'm doing wrong, with my loop, and why its calculating like that.
    private void calculateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_calculateButtonActionPerformed
    // Number Format
    NumberFormat currency = NumberFormat.getCurrencyInstance();
    // Defined Variable
    double loanAmt = 0;
    double rate = 0;
    double term = 0;
    double monthlyPmt = 0;
    double rateArray [] = {7, 15, 30}; //declaration for rate array
    double termArray [] = {5.35, 5.50, 5.75}; //declaration for term array
    int k [] = new int [3];
    int m;
    /*Calculation formulas and parse user's input on Loan amount and
    user's chooses on Loan rate and term. */
    int a = menu.getSelectedIndex();
    term = termArray[a];
    rate = rateArray[a];
    for (int b = 0; b<k.length; b++);{
    if (a <= 2) {
    try {
    loanAmt = Double.parseDouble(amountField.getText());
    term = termArray[a];
    rate = rateArray[a];
    catch (NumberFormatException e) {
    if (loanAmt > 0) {
    loanAmt = Double.parseDouble(amountField.getText());//get the user's choosen item and parse it to the formula
    double mRate = rate / 12; //Calculate monthly rate;
    double months = term * 12; //calculate how many months in the loan term
    monthlyPmt = (loanAmt * (mRate / (1 - Math.pow((1 + mRate), - months)))); //Formula for Monthly Payment
    //Transfer the calculation result to the Monthly Payment text field
    paymentField.setText(String.valueOf(currency.format(monthlyPmt)));
    //Transfer the amortization result to the Table Text Area
    tableTextArea.append("Payment #");
    tableTextArea.append("\t");
    tableTextArea.append("Monthly Pmt");
    tableTextArea.append("\t ");
    tableTextArea.append("Int Paid");
    tableTextArea.append("\t");
    tableTextArea.append("Principal");
    tableTextArea.append("\t ");
    tableTextArea.append("Balance");
    tableTextArea.append("\t\n");
    double balance = loanAmt;
    for (m = 1; m <= months; m++) {
    double intPmt = balance * mRate; //Calculate the Interest paid
    double prin = monthlyPmt - intPmt;
    balance = balance - prin; // Calculate the Loan Balance
    tableTextArea.append(" \n" + m);
    tableTextArea.append("\t" + currency.format(monthlyPmt));
    tableTextArea.append("\t " + currency.format(intPmt));
    tableTextArea.append("\t" + currency.format(prin));
    tableTextArea.append("\t " + currency.format(balance));
    }//GEN-LAST:event_calculateButtonActionPerformed

    OMG thank you thank you. I have been looking at this for long and i guess i needed someone else's opinion to see my mistake. Also when I checked out what you said, I also notice that I named my array wrong. it should be the arrays i have of {7, 25, 30} is my term, and I have it mark as my rate... lol so stupid of me. But thanks a lot :) I really appreciate it/

  • Mortgage program

    I am working on a Mortgage Calclulator program. I got it to compile and run, but I am not getting the right answer. Any suggestions?
    /*MortgageCalculator
    by Kelly Ankenbrand
    June 25, 2004
    Individual Assignment Week 2
    //class Mortgage {
    class MortgageCalculator {
    public static void main(String arguments[]) {
    //Program Variables
    int LOAN = 200000; // *$200,000 Loan
    int TERM = 360; //*360 months
    double INTERESTRATE = 5.75; //*5.75% interest rate
    double Interest = LOAN * INTERESTRATE;
    double Payment = (LOAN + Interest) / TERM;
    //Output
    System.out.println (" Your monthly payment is $"+ Payment); //*prints monthly payment

    Okay,
    I reworked my code and got what I needed. I greatly appreciate your help. I have listed my code below but now need to 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. However I'm not to use a graphical user interface. Now I am really lost. Please help!
    //Mortgage.java
    public class MortgageCalculator1
    public static void main (String[] args){
    double payment, principal = 200000;
    double annualInterest = .0575;
    int years = 30;
    if (args.length == 3) {
    try {
    principal = Double.parseDouble(args[0]);
    annualInterest = Double.parseDouble(args[1]);
    years = Integer.parseInt(args[2]);
    catch (Exception e) {
    System.out.println("Wrong input " + e.getMessage() );
    System.exit(0);
    print(principal, annualInterest, years);
    } else {
    System.out.println("Usage: java Mortgage principal annualInterest years ");
    System.out.println("\nFor example: java Mortgage 200000 .0575 30 ");
    System.out.println("\nYou will get the output like the following: \n");
         print(principal, annualInterest, years);
    System.exit(0);
    public static double calculatePayment(double principal, double annRate, int years){
    double monthlyInt = annRate / 12;
    double monthlyPayment = (principal * monthlyInt)
    / (1 - Math.pow(1/ (1 + monthlyInt), years * 12));
    return format(monthlyPayment, 2);
    public static double format(double amount, int places) {
    double temp = amount;
    temp = temp * Math.pow(10, places);
    temp = Math.round(temp);
    temp = temp/Math.pow(10, places);
    return temp;
    public static void print(double pr, double annRate, int years){
    double mpayment = calculatePayment(pr, annRate, years);
    System.out.println("The principal is $" + (int)pr);
    System.out.println("The annual interest rate is " + format(annRate * 100, 2) +"%");
    System.out.println("The term is " + years + " years");
    System.out.println("Your monthly payment is $" + mpayment);

  • Can't run java program with GUI

    My computer can run java program properly.
    However, for those program with GUI (using swing),
    my computer is unable to display the GUI.
    What's wrong with it? Is there any PATH I need to set before running GUI program?
    Thanks
    icedgold

    Cut, copy, paste then compile and run this;-import java.awt.*;
    import javax.swing.*;
    public class MyJFrame extends JFrame {
      public MyJFrame() {
          super("My first JFrame");
          Container c  = getContentPane();
          JPanel panel = new JPanel();
          panel.setBackground(Color.white);//  (new Color(255, 255, 255));
          JLabel jl = new JLabel("Yes it works");
          panel.add(jl);     
          c.add(panel);
      public static void main(String[] args) {
        MyJFrame frame = new MyJFrame();
        frame.setSize(180,120);
        frame.setLocation(200, 300);
        frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
        frame.setVisible(true);
    }

  • Photoshop keeps crashing...saying an attempt was made to load a program with incorrect format.  Can anyone help?

    photoshop keeps crashing...saying an attempt was made to load a program with incorrect format.  Can anyone help?

    You can
    Supply pertinent information for quicker answers
    The more information you supply about your situation, the better equipped other community members will be to answer. Consider including the following in your question:
    Adobe product and version number
    Operating system and version number
    The full text of any error message(s)
    What you were doing when the problem occurred
    Screenshots of the problem
    Computer hardware, such as CPU; GPU; amount of RAM; etc.

  • Re: Swing GUI formatting

    I normally use AWT for my program's GUI since they have simple user input. For my current project I decided to use Swing. The program is for capturing the stats for Duplicate Bridge. It has a spread sheet style layout with about 20 rows consisting of labels,text fields and radio buttons to hold the data for each hand played.
    My problem: when openning (File|Open>..) previously saved data, the window/scroll pane underneath the dialog window for choosing the file to open is cleared and then repainted very SLOWLY.
    What can I do to speed up/eliminate the slow repainting?
    A version of this program is at: http://users.mo-net.com/normandpaula/DuplicateScorer.jar
    I'm using Java 1.5 in Windows XP on a 1.3GHz system.
    Thanks,
    Norm

    Thanks for the reply.
    I was using FileDialog and changed it to JFileCHooser. No change. Still had the empty spot where the dialog window had been.
    I then woke up and realized that I was reading the file on the AWT event thread. I moved the file reading code to its own thread and now the empty spot is only a flash. Some what better.
    Norm

  • "could not complete your request because of a program error", PDF format, cs2, xp

    1. When edit picture from pdf (from acrobat 7.0.8) in photoshop cs2 901, source pdf can't be saved after closing image in photoshop.
    2. When opening picture in photoshop pdf format, program return "could not complete your request because of a program error". Pdf is saved from same photoshop on same machine.
    What is that with cs2? I have buy 24 tlp licenses cs2 premium packets and i can't work like in previous version? This is big disapointed for me from adobe.
    How i can resolve above problems?
    OS is legal xp with all s. packs.

    ...this problem is frustrating me now, running intel mac, 10.4.9, PShop 9.02, tried everything without a solution yet, my program error occurs right on launch, change a preference, leave it running in the background, then the icon in my dock starts bouncing at me for attention...
    ...boot from cd and run disk utility - failed
    ...trashing all preferences and settings - failed
    ...re-install pshop, update to 9.02 - failed
    ...boot in safe mode, start pshop and quit, reboot normal mode, start pshop - failed
    ...recreated printers in printer set up - failed
    ...program errors occur when software conflicts arise due to an updated operating system.
    ...so the conclusion i have come up with is it's (according to adobe, apples problem for updating the operating system, and according to apple, adobes problem for updating Pshop), the problem being it is always someone elses problem...
    ...rosetta has a few issues I'm sure with CS2, not sure adobe want us running CS2 in rosetta really, perhaps we'll all get annoyed enough eventually to have to get the CS3 instead...
    ...sod the 9.02 update, uninstall it, reinstall and update to 9.01...
    ...works fine...
    ...except for illustrator cs2 that is, he is quite happy crashing in the background too...
    ...making quark xpress on rosetta look fantastic. what a headache for everyone...
    ...this post might sound intolerable, as it goes i'm very tolerable, my boss ain't though waltzing round wandering why he spends his money on this stuff, well, customers money really...
    Andrew

  • Payment medium program with DME format

    Hi!
    I am working for south african client.
    The standard DME format available for south africa is ACB_ZA ( acb format).
    The payment program used is RFFOZA_A and assigned to payment method "A- ACB clearing".
    But the format given by bank is different.
    So, here i have two options:
    1. Change the DME format through DMEE and other configuration and assign the DME format in Payment medium work bench in payment method country step.
    2.  Copy the  payment program RFFOZA_A to ZRFFZA_A, assign the new DME format to generate DME file in new format.
    is new DME foramt for example ZACB_ZA in payment program ZRFFZA_A?
    regs,
    ramesh

    Hello Ramesh,
    Your description is little confusing and unclear.
    Please clarify what do you mean by the following :
    "is new DME foramt for example ZACB_ZA in payment program ZRFFZA_A?"
    Yes, i can understand that you would like to change the existing format of South Africa in DMEE.
    I can think of the following meanings :
    1.  Assignment of DME format in FBZP "Payment method/Country". Here you use the option 'PMW' and enter the format that you want.
    2. You may also execute the program SAPFPAYM from SE38 and give the payment run details to get the result in the format specified here.
    Hope the above helps. Please let me know if my understanding is not correct.
    Thanks and regards,
    Suresh Jayanthi.

  • Payment medium program for MT103 format

    Hi,
    We had a requirement of generating MT013 format from automatic payment program and we are on ECC 5.0 Version.
    I have tried generating with program RFFOM100, but unable to meet all the requirement for HSBC bank, UK.
    I have another program RU_MT103 in ECC 6.0 but this is not available for ECC 5.0.
    Can anyone suggest the payment medium program to be used to generate MT 103 format.
    Thanks in advance
    Rajesh Angadala

    Hi, I implemented this MT103 two years ago for ECC500;
    At the end I copied program RFFOM100 and created a new ZFFOM103 based on the original one.
    Other option is to use PMW. If I am right I think that SAP provides a PMW format (MT103) and a structure (FPM_SWIFT_103) that I think that could be useful if you are used to PMW.
    I hope this helps
    Rafael Barreda

  • Driver program for NACHA format

    Hello Friends – We need to send ACH Payments in NACHA format. Can you pls let me know if this driver program is already available given by SAP. If so, Pls let me know the driver program I should assign at Payment Methods at Country level.
    Thanks

    Hi,
    Kindly use PMW format ACH_FG_BULK. You need to assign this format in Payment method in Country.
    Documentation of this format specify it is in accordance with version 004000 and conforms to the specifications of the National Automated Clearing House Association (NACHA).
    Please find below screen shot for the same:-
    Regards,
    Anand Raichura

  • Error in module program - Invalid field format( screen error )

    In the module program i have added 1  input field named gv_pallet of 1 character. while processing the transaction when i put value 1 in this input field and press a button i am getting error ' Invalid field format( screen error ) .
    I am not geting any clue whats the eror . can anyone able to tell me the error.
    Point will be guranted .
    Regards

    No need to loop to check whether data is changed after PBO, just check System Field SY-DATAR, it will be set to 'X' if any field was changed.
    So the following code is enough;
    IF SY-DATAR EQ 'X'.
       PERFORM SAVE_DATA.
    ENDIF.
    Regards
    Karthik D

  • Need help with total in my mortgage program

    I have been work on this program and I can't seem to correct how the amount is shown. It gives several numbers after the decimal. Can anyone please help.
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    /* Diana Saddler
    * PRG-421  Java Programming II
    public class mortgage extends JFrame implements ActionListener {
    private JPanel panelAdder;
    private JLabel labela;
    private JLabel labelt;
    private JLabel labelr;
    private JTextField textFieldAmount;
    private JTextField textFieldTerm;
    private JTextField textFieldRate;
    private JTextField textFieldResult;
    private JButton buttonCalc;
    public mortgage() {
      initComponents();
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setVisible(true);
      pack();
      // Add Listeners
      buttonCalc.addActionListener(this);
    public void initComponents() {
    //Initialize Components
    panelAdder = new JPanel();
    labela = new JLabel("Amount");
    textFieldAmount = new JTextField();
    labelt = new JLabel("Term");
    textFieldTerm = new JTextField();
    labelr = new JLabel("Rate");
    textFieldRate = new JTextField();
    textFieldResult = new JTextField();
    buttonCalc = new JButton("Calculate");
    //Set Object Attributes
    textFieldResult.setEditable(false);
    textFieldResult.setColumns(8);
    textFieldAmount.setColumns(6);
    textFieldTerm.setColumns(3);
    textFieldRate.setColumns(3);
    Container contentPane = getContentPane();
    contentPane.setLayout(new FlowLayout());
    //Add the components to the panel
    panelAdder.add(labela);
    panelAdder.add(textFieldAmount);
    panelAdder.add(labelt);
    panelAdder.add(textFieldTerm);
    panelAdder.add(labelr);
    panelAdder.add(textFieldRate);
    panelAdder.add(buttonCalc);
    panelAdder.add(textFieldResult);
    contentPane.add(panelAdder);
        public static void main(String[] args) {
             mortgage frame = new mortgage();
    //calculate
        private void setResultValue() {
       double amount = Double.parseDouble(textFieldAmount.getText());
       double term = Integer.parseInt(textFieldTerm.getText());
       double rate = Double.parseDouble(textFieldRate.getText()) / 100.;
       double result = amount * ( rate * Math.pow ( ( 1 + rate ), term ) ) / ( Math.pow( ( 1 + rate ), term ) - 1 );
       textFieldResult.setText(Double.toString(result));
    public void actionPerformed(ActionEvent event) {
      System.out.println("Action Button");
      String command = event.getActionCommand();
      if ("Calculate".equals(command))
          setResultValue();
    }

    DecimalFormat

  • Concurrent programs - adding output format

    hi all,
    how do you add other output formats in the concurrent programs form in Oracle Applications : 11.5.10.2?
    the options i have are limited to HTML, FO, PCL, PDF, XML. i need to add Excel or XLS if possible.
    thanks
    allen

    Hi Srini,
    Thanks for the suggestion.
    I'm not sure if this is applicable to my situation as I'm using a PL/SQL Stored Procedure to generate the Excel. Then run this as a Request. Afterwards, I click the View Output to view the file.
    I am using the FND_FILE.PUT_LINE(fnd_file.output, string) package to create the file and currently has the extension of PCL but it doesn't automatically open in Excel. I'm guessing Excel does not recognize the file format but it is able to open it if I do it manually.
    Not really my idea but it is the client's request.
    Thanks,
    Allen

  • Does Premiere Pro CS5.5 support MPEG-2 Program Stream export format?

    The title says it all, so I need to know am I able to export video from Premiere Pro CS5.5 in MPEG-2 Program Stream format?
    I'm working on a ad spot for local tv channel and they only accept this format. Any help is appreciated!
    Cheers,
    Juha Tuomimaki

    No, I don't. I'm not an expert what comes to details on all the different video formats, but I'm quite sure that Transport Stream or TS and Program Strean (PS) are two different things.
    Currently I see four options in PR Pro when exporting MPEG-2 and choosing the multiplexing method: MPEG2, DVD, TS and None. Basically, I know that the three last choices are not what I'm looking for, but I'm not sure is the first one (MPEG) same as Program Stream. Or maybe I need to install a whole different codec...? Very confusing.

  • Client/Server Program with GUI

    Hello all...I've been working on an instant messenger type of program, and need a way to keep track of different clients using my server, and then posting that list to my clients' GUI, to show them who is "Online" Also, I am having trouble, letting my server know which client to send a message to...i.e. client1 tries to say "Hello" to client2 but nothing happens... Anyways I gonna keep pluggin away at it but if you have any insight let me know please...Damn I just got this new error a second ago, for no apperent reason...
    ReceivingThread.java [156:1] cannot resolve symbol
    symbol : constructor SendingThread (int)
    location: class SendingThread
    SendingThread sendingThread = new SendingThread(8205);
    ^
    1 error
    ...and here's the code for it, just popped up outta nowhere...thx again!!
    import java.io.*;
    import java.net.*;
    import java.util.StringTokenizer;
    public class ReceivingThread extends Thread {
    private byte[] message;
    private int portNumber;
    private InetAddress address;
    private BufferedReader input;
    private boolean keepListening = true;
    // ReceivingThread constructor
    public ReceivingThread( Socket clientSocket )
    // invoke superclass constructor to name Thread
    super( "ReceivingThread: " + clientSocket );
    // set timeout for reading from clientSocket and create
    // BufferedReader for reading incoming messages
    try {
    clientSocket.setSoTimeout( 5000 );
    input = new BufferedReader( new InputStreamReader(
    clientSocket.getInputStream() ) );
    // handle exception creating BufferedReader
    catch ( IOException ioException ) {
    ioException.printStackTrace();
    } // end ReceivingThread constructor
    // listen for new messages and deliver them to MessageListener
    public void run()
    String message;
    // listen for messages until stoppped
    while ( keepListening ) {
    // read message from BufferedReader
    try {
    message = input.readLine();
    // handle exception if read times out
    catch ( InterruptedIOException interruptedIOException ) {
    // continue to next iteration to keep listening
    continue;
    // handle exception reading message
    catch ( IOException ioException ) {
    ioException.printStackTrace();
    break;
    // ensure non-null message
    if ( message != null ) {
    // tokenize message to retrieve user name
    // and message body
    StringTokenizer tokenizer = new StringTokenizer( message, "|" );
    // ignore messages that do not contain a user
    // name and message body
    if ( tokenizer.countTokens() == 2 ) {
    // send message to the client through SendingThread; fill in proper info
    SendingThread sendingThread = new SendingThread(8205);
    sendingThread.start();
    else
    // if disconnect message received, stop listening
    if ( message.equalsIgnoreCase("DISCONNECT") ) {
    keepListening = false;
    } // end if
    } // end while
    // close BufferedReader (also closes Socket)
    try {
    input.close();
    // handle exception closing BufferedReader
    catch ( IOException ioException ) {
    ioException.printStackTrace();
    } // end method run
    }

    1) The error is down to the fact that you don't have a constructor declared for class SendingThread that accepts an int.
    2) To show who's on line use a static ArrayList at the server side. Everytime a user connects, just do:
    String user = "bob";
    arrayList.add(user);
    ArrayList is serialisable so you can serialise the object and send it over the network to the client. The client can deserialise the object and it will in effect have a copy of the object.
    When the client wants to display the names you just need to iterate over the array list.
    As new users connect you will have to update the list and also inform all other connected users that a new user has connected. You could do this by either pushing the data (client waits for data and server sends it immediately) or pulling the data at regular time intervals. I would suggest the first method as you will (or should) already have a thread set up to listen for incoming data.
    3) For sending messages between two hosts, you might want to set up a direct connection, however you would probably be better off sending message via the server. This makes setting up group chats much easier. Each message could be prefixed with the ID of the intended recipient. For group chat it will will be prefixed with group ID. The server should keep a record of group ID's to find out who's in each group.

Maybe you are looking for

  • SAP PI 7.1 Mapping resource not found

    Hello Gururs, We have been experiencing the issue on our QA SAP PI system after upgrade to 7.1 eHP1. We just imported new set of components under new SWCV and namespace. While trying to process the message, getting below error. I already checked all

  • Help needed to DELETE a System created with Logical Components assigned.

    Hi, I created a system in SMSY in my Solution Manager system. I unknowingly assigned the system to Logical Components. Now on finding that it was a worng way of configuration I need to DELETE the system and recreate it using the option "Create new sy

  • Can no longer close tabs by clicking wheel button in FF-4

    I have a basic optical mouse and extension Tab Mix Plus. I was always able to close the tab that I was in (anywhere within the page) by clicking the center wheel button. This was very convenient. I can close the tab by putting the mouse pointer on th

  • XML Signatures - How To ?

    I need of help how to organize a XML structure for hierarchical (nested) signature scheme. For example: Signed Object 1: O1 Signatures Level 1: - S1.1 signs O1; - S1.2 signs O1; Signature Level 2: - S2.1 signs O1, S1.1 and S1.2 - S2.2 signs O1, S1.1

  • My iTunes is not working and it keeps coming up with Microsoft Outlook and stuffing my iTunes account up

    Something is really wrong with my iTunes account ever since this Outllook come one my iTunes account and Microsoft told me to contacted you about it and my hole iTunes account is playing up as well will not sync because of this outlook thing and my i