Home Answers Viewqa Java-Beginners java loan calculator applet help

 
 


Mike
java loan calculator applet help
0 Answer(s)      5 months and 8 days 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()
{
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 Pages:
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
Calculator
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
Calculator class
Calculator class  I am a beginner in Eclipse. I have to do a program called calculator that adds numbers. This is my code so far: //Margaret //ICS... for this generated file go to * Window - Preferences - Java - Code Style - Code Templates
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
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
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
Applet - Applet
------------------------"); g.drawString("Demo of Java Applet Window Event Program"); g.drawString("Java...Applet   Namaste, I want to create a Menu, the menu name is "Display... "shortcut key" and "Version" menu item, the frame should be is open. Plz help me
Swimming Pool Calculator - Java Beginners
Swimming Pool Calculator  When I run the program the login window doesn't appear...Please help 1)LoginForm.java import javax.swing.*; import...()); mainFrame = new JFrame("Swimming Pool Volume Calculator"); calcButton = new
applet running but no display - Applet
, it is showing that the "Applet as1 started". Please help me to solve this issue... strDefault = "Hello! Java Applet."; public void paint(Graphics g) { String...applet running but no display  Hai, Thanks for the post. I have
Simple Calculator Application In Java Script
Simple Calculator Application In Java Script  ... Calculator The objective of this project is  learn how to write a simple calculator with the JavaScript programming language. You will learn how to write
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
Graphical calculator using AWT - Java Beginners
Graphical calculator using AWT  hi Sir, I need a source code for the following prgm...pls help me.. Implement a simple graphical calculator using AWT.The calculator shd perform simple operation like addition, subtraction
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
Applet
Applet  Draw the class hierarchy of an Applet class. Also explain how to set background and forground colors in java
java - Applet
java  How can i develop an expert system using applets? can you help me with some sample source code
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
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
applet
applet  what is applet in java   An applet is a small program that can be sent along with a Web page to a user. Java applets can perform... the following link: Applet Tutorials
iPhone EMI Calculator, EMI Calculator for iPhone
Loan Calculator (ALC). The ALC tool informs you about the affordable eligibility... Calc using Affordable Loan Calculator tab. How to use this tool? Using our EMI.... EMAIL On the foot side, three tabs will appear: EMI Calculator, Affordable Loan
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
Applet
Applet  Write a Java applet that drwas a line between 2 points. The co-ordinates of 2 points should be passed as parametrs from html file. The color of the line should be red
age calculator
age calculator  sir , actually m working on a project where i want the user to enter his date of birth in a jtextfield .and on doing so his age should b displayed in the next textfield automatically....plz help
how can i calculate loan - Java Interview Questions
how can i calculate loan  negotiating a consumer loan is not always straightforward.one 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
Rad Calculator
Rad Calculator  sir/mam pls help me i need javaME moblie application Source Half life (minutes) :109.70 Request mCi: 100 Filled time: 03:15 AM Dispatch time : 04:15 AM Filled time & Dispatch time difference
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
Applet Graph
Applet Graph  hai, iam new to java plz help me.. 1..i have a table of information(column names) from database(mysql) 2..i have to select any two... a graph between those columns in a applet plz send me the code thank u
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 progam - Applet
java progam  write to me java program on simple calculator  Hi Friend, Please visit the following link: http://www.roseindia.net/java/example/java/swing/calculator-in-swing.shtml Hope that it will be helpful
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
thread program for calculator implementation
thread program for calculator implementation  Hi i'm prem i need calculator progrm in java that are implemented by Thread interface.....pls strong text
unable to see the output of applet. - Applet
unable to see the output of applet.  Sir, I was going through the following tutorial http://www.roseindia.net/java/example/java/applet...://www.roseindia.net/java/example/java/applet/FirstApplet.html but the problem
calculator - Java Server Faces Questions
calculator  Some ideas for the project of calculator
Program for Calculator - Swing AWT
Program for Calculator  write a program for calculator?  Hi Friend, Please visit the following link: http://www.roseindia.net/java/example/java/swing/calculator-in-swing.shtml Hope that it will be helpful
Java program - Applet
Java program  Can you please provide me a code for scientific calculator in java I need that in urgent.Please post me the answers  Hi Friend, Please visit the following link: http://www.roseindia.net/tutorial/java
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
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
applet - Applet
in Java Applet.",40,20); } } 2) Call this applet with html code...: http://www.roseindia.net/java/example/java/applet/ Thanks....  Hi Friend, Try the following code: 1)Create an applet
Applet - Applet
, Applet Applet is java program that can be embedded into HTML pages. Java applets... in details to visit.... http://www.roseindia.net/java/example/java/applet...Applet  what is the concept of applet? what is different between
Swing - Applet
Swing  Hello, I am creating a swing gui applet, which is trying... to exaplain. Can you please help me?  Hi friend, import... information on swing visit to : http://www.roseindia.net/java/example/java
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
Allegrograph with java applet - Java Beginners
Allegrograph with java applet  how to start with java applet when related to semantic. im using allegrograph to do it..pls help
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
core java - Applet
core java  how can draw a single line with mouse in applet. please help me   Hi Friend, Create an applet 'SimpleDrawApplet.java... the applet with html file: Java Applet Demo Put your html file
java applet run time error - Applet
java applet run time error  Hi, Im new to java applet.please help me. i have create a MPEG movie player in applet. when i run that program... javax.media.*; public class PlayerApplet extends Applet implements ControllerListener

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.