java loan calculator applet help



Share on Google+Share on Google+

java loan calculator applet help
0 Answer(s)      4 years and 11 months ago
Posted in : Java Beginners

Hi, I could use some help correcting a code here. I need to write a Java applet program (together with its html test file) to calculate loan payments. The user will provide the interest rate, the number of years, and loan amount.

this is what I have so far

import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;

public class LoanCalculator extends JApplet
implements ActionListener
private JTextField jtfInterestRate = new JTextField(10);
private JTextField jtfYear = new JTextField(10);
private JTextField jtfLoan = new JTextField(10);
private JTextField jtfMonthlyPay = new JTextField(10);
private JTextField jtfTotalPay = new JTextField(10);

private JButton jbtCompute = new JButton("Compute Payment");

public LoanCalculator()


JPanel p1 = new JPanel();
p1.setLayout(new GridLayout(5, 2));
p1.add(new Label("Interest Rate (e.g., 5.5 for 5.5%)"));
p1.add(new Label("Years "));
p1.add(new Label("Loan Amount"));
p1.add(new Label("Monthly Payment"));
p1.add(new Label("Total Payment"));
p1.setBorder(new TitledBorder(
"Enter interest rate, year and loan amount"));

JPanel p2 = new JPanel();
p2.setLayout(new FlowLayout(2));

add(p1, "Center");
add(p2, "South");


public void actionPerformed(ActionEvent e)
if (e.getSource() == this.jbtCompute)
double interest =
int year =
double loanAmount =

Loan loan = new Loan(interest, year, loanAmount);

this.jtfMonthlyPay.setText(String.format("%.2f", new Object[] { Double.valueOf(loan.getMonthlyPayment()) }));
this.jtfTotalPay.setText(String.format("%.2f", new Object[] { Double.valueOf(loan.getTotalPayment()) }));

public static void main(String[] args)
JFrame frame = new JFrame("Loan Calulator");

LoanCalculator applet = new LoanCalculator();

frame.add(applet, "Center");


frame.setSize(350, 250);

The error I keep getting here is at line 71 (Loan loan = new Loan(interest, year, loanAmount); that java cannot find symbol and it points to where Loan is after new.

I've tried adding in a NoClassDefErrorException import and that didn't work. I tried changing the name of the code and that didn't work either. I've even tried adding a public class loan in the main method but I realized then that a class can't be declared twice in the main method.

I know that nothing in the above code indicates that I actually have a Loan class. his implies that you have a Loan class in the file somewhere and it should be in the same directory than How can I correct this error. thanks

View Answers

Related Tutorials/Questions & Answers:
java loan calculator applet help
java loan calculator applet help  Hi, I could use some help correcting a code here. I need to write a Java applet program (together with its html...); that java cannot find symbol and it points to where Loan is after new
loan calculator
loan calculator  code of the loan clculator
matrix calculator - Java Beginners
matrix calculator  hi..... can you help me in writing source code of matrix calculator in java... i know you are the best you can do it!!! show yourself
base calculator.. - Java Beginners
base calculator..  Help, i need some help about a base calculator.. i don't know how to start
calculator - Java Interview Questions
calculator  create calculator by java code  Hi Friend, Please visit the following link: Thanks
base calculator.. - Java Beginners
base calculator..  need some help!!! I cant install jcreator properly?? there's always an error (Error : Invalid path, "C:\Program Files\Java\jre1.6.0_01\bin\javac.exe" -classpath "C:\Program Files\Java\jdk1.6.0_01\bin" -d "C
calculator in java with stack
calculator in java with stack  i want calcultor with interface in java and in interface there is button called postfix ,,, when the user enter... then result plz help me i have project in it ,,i must make interface like that and every
simple calculator - Java Beginners
simple calculator  how can i create a simple calculator using java codes?  Hi Friend, Please visit the following link: Thanks
Scientific Calculator - Java Beginners
Scientific Calculator  Develop a scientific calculator using even-driven programming paradigm of Java.? Thanks in ADVANCE  Hi Friend, Please visit the following link:
Calculator  need a simple java program to degin a CALCULATOR without using ADVANCED JAVA....   Calculator in Java Swing
java applet problem - Applet
java applet problem  i was doing a program using java applet. I want to make a simple calculator. So i added four labels,textboxes. And 6 buttons...*; import java.awt.*; public class Calculator extends Applet implements
need help to create applet
need help to create applet  Can u help me..?? I get a task ...and i dont know how to make it... So I hope that u can help me... Here is the task... ~Create an Applet using all Layout Manager(use whatever component in each
Simple Java Calculator - Java Beginners
Simple Java Calculator  Write a Java program to create simple Calculator for 4 basic Math operations, Addition, Subtraction, Multiplication and Division. The calculator should simulate the look of handheld calculator containing
Java Calculator Program
Java Calculator Program  Hi, so I need to make a program that "works like a calculator". I need to make two versions: 1) I'm given the Expression Class and need to implement the children classes, which are Number, Product, Sum
Java Applet
Java Applet   How to add Image in Java Applet? what is getDocumentBase
java applet - Applet
java applet  wants to creat address bar on my java applet.  Hi Applet don't provide a facility to create a address bar directly. You just create a text box. In this text box if you enter any http address
loading Java Applet - Applet
loading Java Applet  Hi, I use the archive tag to download my applet into the Browser It takes too long to load. Can I do it in several steps... control the loading within the applet? thanks
java - Applet
java  how to connect database table with scrollbar in java applet
java - Applet
java  how to connect database table with scrollbar in java applet
java - Applet
java  what is applet?  Hi Friend, Please visit the following link: Thanks
java applet - Applet
java applet  I want to close applet window which is open by another button of applet program. plz tell me!   Hi Friend, Try...:// Thanks
Java Calculator program - Java Beginners
Java Calculator program  import java.awt.*; import javax.swing.*; import java.awt.event.*; class Calculator implements ActionListener { int c,n...:// Hope
calculator - Java Server Faces Questions
calculator  Some ideas for the project of calculator
java applet
java applet  why java applet programs doesn't contain main method
java applet
java applet  why java applet programs doesn't contain main method
disable keyboard in java applet
disable keyboard in java applet  How to disable key board of my client in an java applet embedded in a website while the applet is running.? Plz help
Java applet
Java applet  What tags are mandatory when creating HTML to display an applet
Java applet
Java applet   How do I go from my applet to another JSP or HTML page
java applet
java applet  If i insert in database from applet this work, but from applet.html don't
Java Applet
Java Applet  Hi, What is Java Applet and how it can be useful in development of Java programs? Can anyone tell me the url to learn Java Applet? Thanks   Hi, See the tutorial at: Applications and Applets Thanks
how can i calculate loan - Java Interview Questions
how can i calculate loan  negotiating a consumer loan is not always form of loan is the discount installment loan, which works as follows. suppose a loan has a face value of 1,000 by 0.15 to yield 225


Advertisement null