Patty Edens

Greenhorn
+ Follow
since May 20, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Patty Edens

That worked - Thank you!!
20 years ago
Hi Sorry about that! Here's all the code. PaymentObject is being used to tie the gui program and event program together.

//import necessary classes
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class MortgageEventWk4 implements ActionListener
{

//links this event class with the main classes and names the object
Pattys_Mortgage_Wk4 PaymentObject;
Thread Mortgage;

//constructor method - creates the ojbect based on the methods
//within main class
public MortgageEventWk4(Pattys_Mortgage_Wk4 in)
{
PaymentObject = in;
} //end of method


//declare variables
//double amountLoan;
//double amountNoPayments;
//double rateAmount;
//double payAmount;
double amountPayment;
double paymentsNo;

//Create the method that will call the event to initialize the
//ActionListener event. Determine the event's source and state.
public void actionPerformed(ActionEvent event)
{
//process the user action
String command = event.getActionCommand();
if (command == "Reset")
reset();
if (command == "Pause")
pause();
if (command == "Continue")
cont();
if (command == "7 Years at 5.35%")
{
//hold for correct code
}
if (command == "15 Years at 5.5%")
{
//hold for correct code
}
if (command == "30 Years at 5.75%")
{
//hold for correct code
}
}//end method



void reset()
{
PaymentObject.pause.setEnabled(true);
PaymentObject.cont.setEnabled(true);
PaymentObject.reset.setEnabled(true);
PaymentObject.amount.setText(null);
PaymentObject.rate.setText(null);
PaymentObject.term.setText(null);
PaymentObject.paymentsNo.setText(null);
PaymentObject.amountPayment.setText(null);
PaymentObject.manualEntry.setSelected(false);
PaymentObject.menuEntry.setSelected(false);
}//end of method

void cont()
{
PaymentObject.pause.setEnabled(true);
PaymentObject.cont.setEnabled(false);
PaymentObject.reset.setEnabled(true);
}//end of method

void pause()
{
PaymentObject.pause.setEnabled(false);
PaymentObject.cont.setEnabled(true);
PaymentObject.reset.setEnabled(true);
}//end of method


//run method - main part of code
public void run()
{
Thread TheThread = Thread.currentThread();

while (Mortgage == TheThread)
{
double loanAmt = Double.parseDouble(PaymentObject.Mortgage.getText());
double numOfPayments = Double.parseDouble(PaymentObject.term.getText())*12;
double rateAmt = Double.parseDouble(PaymentObject.rate.getText())/100/12;
double payAmt = (loanAmt*rateAmt) / (1-(Math.pow((1+rateAmt),
(-1*numOfPayments))));
PaymentObject.paymentsNo.setText(numOfPayments);
PaymentObject.amountPayment.setText(payAmt);
}//end method

}//end of method

}//end of method
20 years ago
Hi,
I'm having trouble with two lines of set.text code. The error message is cannot resolve symbol which I know this means the code cannot identify what this meand - my problem is I'm not sure why. I have the variables identified. I did remove some Decimal.format code because at this stage it wasn't needed and I couldnt get it to work. Here's a snippet of code - Hope someone can help.

double loanAmt = Double.parseDouble(PaymentObject.Mortgage.getText ());
double numOfPayments = Double.parseDouble(PaymentObject.term.getText())*12;
double rateAmt = Double.parseDouble(PaymentObject.rate.getText())/100/12;
double payAmt = (loanAmt*rateAmt) / (1-(Math.pow((1+rateAmt),
(-1*numOfPayments))));
PaymentObject.paymentsNo.setText(numOfPayments);
PaymentObject.amountPayment.setText(payAmt);
20 years ago
Hi, I got it to work Thanks everyone for the help!! I had an abstract error and then got a exception thrown - main message. I had the main class coded incorrectely.
20 years ago
Sorry for the confusion - I can't get the MortgageEvent program to compile. I tired the recommended changes but the program is still not working.
20 years ago
I'm working on a mortgage calculator program for school. I cannot get the Event to work properly and exhausted myself trying to figure out what I'm doing wrong - which is probably something really stupid - cause I'm feeling really stupid right now. My code is below - can someone give me an idea of what (probably everything) I'm doing wrong. I was referred to a program in "Sams, Teach Yourself Java 2 in 24 hours that is pulling a Thread - I don't think I need a thread but now don't know how to get rid of it. My double.parseDouble is not working either. Any help would be appreciated.

The code:

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public class MortgageEvent extends JFrame implements ActionListener {

Pattys_Mortgage gui;
Thread calculating;

public MortgageEvent(Pattys_Mortgage in) {
gui = in;
}

void startCalculating() {
calculating = new Thread(this);
calculating.start();
gui.calculate.setEnabled(false);
gui.quit.setEnabled(true);
gui.reset.setEnabled(false);
}

void stopCalculating() {
gui.quit.setEnabled(false);
gui.calculate.setEnabled(true);
gui.reset.setEnabled(true);
calculating = null;
}

void clearAllFields() {
gui.mortgage.setText(null);
gui.term.setText(null);
gui.interest.setText(null);
}

public void actionPerformed(ActionEvent calculate) {
String command = calculate.getActionCommand();
if(command == "Calculate")
startCalculating();
if(command == "Quit")
stopCalculating();
if(command == "Reset")
clearAllFields();
//declare variables
double amount = Double.parseDouble(mortgage.getText());
double term = Double.parseDouble(term.getText());
double rate = Double.parseDouble(rate.getText());
double results = Double.parseDouble(results.getText());
double noOfPayments = Double.parseDouble(noOfPayments());
}

public static double results(double amount, double noOfPayments,
double rate) {
double payment = ((amount*rate)/12/
(1-(Math.pow((1+(rate/12)),(-1*noOfPayments)))));
return payment;
//double.parseDouble(results.getText());
}

static public double parseDouble(results.getText())
{
return doubleValueOf(results);
}
}
20 years ago