Need help PLEASE!!!

I have the following calculator that I am in desperate need of help with...

I have to make the switch statement into a seperate file and have it read into the program.

Can someone PLEASE give me some guidance and maybe a little nudge in the right direction? Here is my code so far:

import java.awt.*;

import java.text.*;

import java.applet.*;

import java.awt.event.*;

import java.awt.Container;

import java.lang.Object;

import javax.swing.*;

import javax.swing.JLabel;

import javax.swing.JTextField;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.io.File;

publicclass MortgageCalcWk4extends JAppletimplements ActionListener

{

//Declaring Labels, TexFields and Greeting

JLabel greetingLabel =new JLabel("Welcome to My Mortgage Calculator");

JLabel amountLabel =new JLabel("Amount:");

JLabel rateLabel =new JLabel("Interest Rate: ");

JLabel yearsLabel =new JLabel("Years: ");

JLabel termLabel =new JLabel("Select your Terms");

JLabel payLabel =new JLabel("You're Mortgage Payment is:");

JLabel scheduleLabel =new JLabel("Below is your Amortization Schedule:");

JButton calculateButton =new JButton("Calculate");

JTextField amountField =new JTextField("", 10);

JTextField paymentField =new JTextField("", 10);

JTextField rateField =new JTextField("", 10);

JTextField yearsField =new JTextField("",10);

JTextArea amortText;

JScrollPane amortScroll;

String sOut =null;

publicvoid init()

{

//Setting up the Layout Manager

SpringLayout layout =new SpringLayout();

getContentPane().setLayout(layout);

paymentField.setEditable(false);

rateField.setEditable(true);

yearsField.setEditable(true);

amortText=new JTextArea(25,60);

amortScroll=new JScrollPane(amortText);

//Adjusting constraints for labels

layout.putConstraint(SpringLayout.WEST, greetingLabel,

250,

SpringLayout.WEST, getContentPane());

layout.putConstraint(SpringLayout.NORTH, greetingLabel,

0,

SpringLayout.NORTH, getContentPane());

layout.putConstraint(SpringLayout.WEST, amountLabel,

25,

SpringLayout.WEST, getContentPane());

layout.putConstraint(SpringLayout.NORTH, amountLabel,

50,

SpringLayout.NORTH, getContentPane());

layout.putConstraint(SpringLayout.WEST, termLabel,

25,

SpringLayout.WEST, getContentPane());

layout.putConstraint(SpringLayout.NORTH, termLabel,

100,

SpringLayout.NORTH, getContentPane());

layout.putConstraint(SpringLayout.WEST, payLabel,

130,

SpringLayout.WEST, getContentPane());

layout.putConstraint(SpringLayout.NORTH, payLabel,

188,

SpringLayout.NORTH, getContentPane());

layout.putConstraint(SpringLayout.WEST, scheduleLabel,

250,

SpringLayout.WEST, getContentPane());

layout.putConstraint(SpringLayout.NORTH, scheduleLabel,

235,

SpringLayout.NORTH, getContentPane());

layout.putConstraint(SpringLayout.WEST, rateLabel,

260,

SpringLayout.WEST, getContentPane());

layout.putConstraint(SpringLayout.NORTH, rateLabel,

50,

SpringLayout.NORTH, getContentPane());

layout.putConstraint(SpringLayout.WEST, yearsLabel,

510,

SpringLayout.WEST, getContentPane());

layout.putConstraint(SpringLayout.NORTH, yearsLabel,

50,

SpringLayout.NORTH, getContentPane());

//Adjusting constraints for textfields

layout.putConstraint(SpringLayout.WEST, amountField,

75,

SpringLayout.WEST, getContentPane());

layout.putConstraint(SpringLayout.NORTH, amountField,

48,

SpringLayout.NORTH, getContentPane());

layout.putConstraint(SpringLayout.WEST, paymentField,

300,

SpringLayout.WEST, getContentPane());

layout.putConstraint(SpringLayout.NORTH, paymentField,

186,

SpringLayout.NORTH, getContentPane());

layout.putConstraint(SpringLayout.WEST, rateField,

340,

SpringLayout.WEST, getContentPane());

layout.putConstraint(SpringLayout.NORTH, rateField,

48,

SpringLayout.NORTH, getContentPane());

layout.putConstraint(SpringLayout.WEST, yearsField,

552,

SpringLayout.WEST, getContentPane());

layout.putConstraint(SpringLayout.NORTH, yearsField,

48,

SpringLayout.NORTH, getContentPane());

//Adjusting constraints for combo boxes

layout.putConstraint(SpringLayout.WEST, terms,

25,

SpringLayout.WEST, getContentPane());

layout.putConstraint(SpringLayout.NORTH, terms,

125, SpringLayout.NORTH, getContentPane());

layout.putConstraint(SpringLayout.WEST, amortScroll,

20, SpringLayout.WEST, getContentPane());

layout.putConstraint(SpringLayout.NORTH, amortScroll,

255, SpringLayout.NORTH, getContentPane());

//Adjusting constraint for button

layout.putConstraint(SpringLayout.WEST, calculateButton,

25,

SpringLayout.WEST, getContentPane());

layout.putConstraint(SpringLayout.NORTH, calculateButton,

185,

SpringLayout.NORTH, getContentPane());

//Displays Labels, TextFields and Combo box in the Applet

getContentPane().add(greetingLabel);

getContentPane().add(amountLabel);

getContentPane().add(amountField);

getContentPane().add(termLabel);

getContentPane().add(terms);

getContentPane().add(amortScroll,BorderLayout.CENTER);

getContentPane().add(calculateButton);

getContentPane().add(payLabel);

getContentPane().add(paymentField);

getContentPane().add(scheduleLabel);

getContentPane().add(rateLabel);

getContentPane().add(rateField);

getContentPane().add(yearsLabel);

getContentPane().add(yearsField);

calculateButton.addActionListener(this);

terms.addActionListener(this);

}

//Terms for combo box menu

String[] termsArray ={"7 years at 5.35%","15 years at 5.5%","30 years at 5.75%"};

JComboBox terms =new JComboBox(termsArray);

publicvoid actionPerformed(ActionEvent thisEvent)

{

amortText.setText("");

paymentField.setText("");

//Establishing local variables

double amt= 0;

double rate = 0;

double months = 0;

Object src = thisEvent.getSource();

if(src.equals(terms)){

int menuNum = terms.getSelectedIndex();

switch(menuNum){

case 0:

rate = 5.35;

months = 84;

break;

case 1:

rate = 5.5;

months = 180;

break;

case 2:

rate = 5.75;

months = 360;

break;

default:

rate = 5.35;

months = 84;

break;

}

rateField.setText("" + rate);

yearsField.setText("" + (months / 12));

}else{// if src.equals(calculateButton)

try{

amt = Double.parseDouble(amountField.getText());

rate = Double.parseDouble(rateField.getText());

months = Double.parseDouble(yearsField.getText());

}catch(NumberFormatException nfe){

JOptionPane.showMessageDialog(

null,

"Enter numeric values for all fields",

"Input Error",

JOptionPane.WARNING_MESSAGE);

return;

}

double dMonthlyInterest;

double dMonthlyPrincipal;

double dPayment=0;

double dBalance = amt;

//Formulas for determining payment amount

double dMonthly = (rate /1200);

dPayment = (amt * dMonthly) / (1-Math.pow(1+dMonthly, -(months*12)));

dMonthlyInterest = (amt * dMonthly);

dMonthlyPrincipal = (dPayment - dMonthlyInterest);

NumberFormat currencyFormatter = NumberFormat.getCurrencyInstance();

DecimalFormat format =new DecimalFormat("0.00");

String currencyOut = currencyFormatter.format(dPayment);

paymentField.setText(currencyOut);

sOut =null;

for(int i=1; i<=(months*12); i++){

// Reduces Principle each month

dMonthlyInterest = (dBalance * dMonthly);

dMonthlyPrincipal = (dPayment - dMonthlyInterest);

dBalance = (dBalance - dMonthlyPrincipal);

//Determining monthly payment

dPayment = (amt * dMonthly) / (1 - Math.pow ((1 + dMonthly), - (months*12)));

if(sOut ==null){

sOut ="Payment " + Integer.toString(i) +"\tInterest Paid: "

+ currencyFormatter.format(dMonthlyInterest) +"\tRemaining Balance: "

+ currencyFormatter.format(dBalance) +"\r\n";

}else{

sOut = sOut +"Payment "+ Integer.toString(i) +"\tInterest Paid: "

+ currencyFormatter.format(dMonthlyInterest) +"\tRemaining Balance: "

+ currencyFormatter.format(dBalance) +"\r\n";

}

amortText.setText(sOut);

}

}

}

}

[13060 byte] By [Bob123a] at [2007-10-2 7:28:55]
# 1
All of these Java Genius' in here and no one can throw me a bone?
Bob123a at 2007-7-16 21:07:18 > top of Java-index,Java Essentials,Java Programming...
# 2
> I have to make the switch statement into a seperate file and have it read into the program.I'm assuming you don't have to read the switch statement into your program, it doesn't look like that kind of program. So would you like to explain WTF that actually means?
DrClapa at 2007-7-16 21:07:18 > top of Java-index,Java Essentials,Java Programming...
# 3

> All of these Java Genius' in here and no one can throw me a bone?

Instead of spending time making silly comments, why don't you spend time making questions the people understand. I think something like this is what you want.

1) Create a file with the data something like this:

5.35|84

5.5|180

5.75|360

5.35|84

2) Read each row in the file and parse the data

3) Build an custom object to store the data

4) Add the object to the combo box. Here's an example that should help you out:

http://forum.java.sun.com/thread.jspa?forumID=57&threadID=613731

camickra at 2007-7-16 21:07:18 > top of Java-index,Java Essentials,Java Programming...
# 4
> All of these Java Genius' in here and no one can> throw me a bone?Nice. That's a great way to talk to people whom you're trying to get to help you, a complete stranger, on their own time.I, for one, will be ignoring your questions from now on.
jverda at 2007-7-16 21:07:18 > top of Java-index,Java Essentials,Java Programming...
# 5
Thank you very much. I didn't mean to come across like you took it. I was only saying that with all of the guru's in this forum, there should be someone that would be able to help me out.
Bob123a at 2007-7-16 21:07:18 > top of Java-index,Java Essentials,Java Programming...
# 6

> > I have to make the switch statement into a seperate

> file and have it read into the program.

>

> I'm assuming you don't have to read the switch

> statement into your program, it doesn't look like

> that kind of program. So would you like to explain

> WTF that actually means?

I have to pull the switch statement out and place it in it's own file.

Then create a Reader statement to pull the data back into the mortgage program. Make any sense? It sure doesn't to me...

Bob123a at 2007-7-16 21:07:18 > top of Java-index,Java Essentials,Java Programming...