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 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()
{
this.jtfMonthlyPay.setEditable(false);
this.jtfTotalPay.setEditable(false);

this.jtfInterestRate.setHorizontalAlignment(4);
this.jtfYear.setHorizontalAlignment(4);
this.jtfLoan.setHorizontalAlignment(4);
this.jtfMonthlyPay.setHorizontalAlignment(4);
this.jtfTotalPay.setHorizontalAlignment(4);

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(this.jtfInterestRate);
p1.add(new Label("Years "));
p1.add(this.jtfYear);
p1.add(new Label("Loan Amount"));
p1.add(this.jtfLoan);
p1.add(new Label("Monthly Payment"));
p1.add(this.jtfMonthlyPay);
p1.add(new Label("Total Payment"));
p1.add(this.jtfTotalPay);
p1.setBorder(new TitledBorder(
"Enter interest rate, year and loan amount"));

JPanel p2 = new JPanel();
p2.setLayout(new FlowLayout(2));
p2.add(this.jbtCompute);

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

this.jbtCompute.addActionListener(this);
}

public void actionPerformed(ActionEvent e)
{
if (e.getSource() == this.jbtCompute)
{
double interest =
Double.valueOf(this.jtfInterestRate.getText()).doubleValue();
int year =
Integer.valueOf(this.jtfYear.getText()).intValue();
double loanAmount =
Double.valueOf(this.jtfLoan.getText()).doubleValue();

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");

applet.init();
applet.start();

frame.setSize(350, 250);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}

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 Loan.java somewhere and it should be in the same directory than LoanCalculator.java. 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
Advertisements
ModuleNotFoundError: No module named 'loan-calculator'
ModuleNotFoundError: No module named 'loan-calculator'  Hi, My... named 'loan-calculator' How to remove the ModuleNotFoundError: No module named 'loan-calculator' error? Thanks   Hi, In your python
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
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
base calculator.. - Java Beginners
base calculator..  Help, i need some help about a base calculator.. i don't know how to start
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
Calculator
Calculator  need a simple java program to degin a CALCULATOR without using ADVANCED JAVA....   Calculator in Java Swing
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
Can you help me with applet?
Can you help me with applet?  I'm very new to applet, and i'm weak in graphic design part. How can i add the graphic in my test project? Can you help me with this: import java.io.*; import java.util.*; import javax.swing.
calculator - Java Interview Questions
calculator  create calculator by java code  Hi Friend, Please visit the following link: http://www.roseindia.net/java/example/java/swing/calculator-in-swing.shtml 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...://www.roseindia.net/java/example/java/applet/ Thanks
Java Applet
Java Applet   How to add Image in Java Applet? what is getDocumentBase
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: http://www.roseindia.net/java/example/java/swing/calculator-in-swing.shtml 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: http://www.roseindia.net/java/example/java/applet/ 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: http://www.roseindia.net/tutorial/java
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  why java applet programs doesn't contain main method
java applet
java applet  why java applet programs doesn't contain main method
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  what is applet
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
java - Applet
java  how to communicate to my servlet through applet.   ... this information to the servlet in the normal way. The applet pretends... is concerned, the applet is just another HTTP client. For more infomation
java applet notpad
java applet notpad  i need Codes Or programe in java applet ; i want add this programe to my site html > please help me our   Learn Java...: Java Applet Tutorials
java applet
java applet   I want code to implement (1) user will enter how many nodes (2)it should allow that no. of clicks and circle should be displayed at that position
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  Creation of Applet for Personal Details Form When a customer places his first order of garments, the Personal Details Form is displayed.... The applet must include the following validations: ï?® The FirstName, Address1
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 - Applet
java  i have button browse button in my applet form.when i click on browse button i have to go to file storage box(what ever files stored in my... in the mail).i have display that file path in my applet form.am learner please send me
calculator - Java Server Faces Questions
calculator  Some ideas for the project of calculator
java applets - Applet
java applets  hiiiii... i need ur help in usage of java code for navigation of one applet window to other...?? can you plz respond to me
java applet prog
java applet prog  applet to display scrolling text from right to left in an applet window using thread. text should be accepted by html parameter
java - Applet
java  1.An applet program to draw a line graph for y=2x+5.[for suitable values of x & y] 2. An applet program to draw following shapes (1)cone... java.applet.Applet; public class CubeExample extends Applet { Stroke
Applet - Java Beginners
Applet  sir, I have just started applet. Now i am going to design my resume using java. Now, if I want to attach my photo, which code will suitable for that?? please help
Java Image Browsing Applet
Java Image Browsing Applet  Hi. I want to create an applet which is embedded in html page which display image by browsing the files in the computers hard disk... Please help me out
java - Applet
java  Hi, I need very urgent code............ please help me......... How to convert text to wave conversion? I need java code............ Regards, Valarmathi
Java applet
Java applet  I wanted as many clicks are there ,circles should be displayed there. I tried this code but it erases previous circles. plz help. public void mouseClicked(MouseEvent m) { x=m.getX(); y=m.getY
Java applet
Java applet  I wanted as many clicks are there ,circles should be displayed there. I tried this code but it erases previous circles. plz help. public void mouseClicked(MouseEvent m) { x=m.getX(); y=m.getY
Java Applet
Java Applet  Hi, I have a query, on every mouse click an oval should be drawn. But in my program I have used repaint() function, therefore...;i<4;i++) g.drawOval(x,y,30,30); } Pls help
Java Applet
Java Applet  Hi, I have a query, on every mouse click an oval should be drawn. But in my program I have used repaint() function, therefore...;i<4;i++) g.drawOval(x,y,30,30); } Pls help
java - Applet
java  How can i develop an expert system using applets? can you help me with some sample source code
How to Write a Calculator Program in Java?
How to Write a Calculator Program in Java? In this Java Tutorial you will learn how to write a Calculator program in Java in easy steps. Calculator program..._TO_REPLACE_2 Example of Calculator program in Java package Tutorial
Calculator
Calculator  Dear Friends, I need code (or advice) for to calculate the value based on my policy name,policy value and policy duration for my mini project in jsp-servlet. Help Me to solve. Advance thanks you dear friend

Ads