Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners java loan calculator applet help
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Mike
java loan calculator applet help
0 Answer(s)      2 years 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


Advertisement
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
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 - 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
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
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
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
Calculator
Calculator  need a simple java program to degin a CALCULATOR without using ADVANCED JAVA....   Calculator in Java Swing
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
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
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
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
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
loan repayment
loan repayment  Monthly installment calculation is (Loan Amount / (12 * number of years of year repayment)) + 7% of (loan Amount) In case... % of monthly installment * n A customer can also check the status of the loan
calculator - Java Server Faces Questions
calculator  Some ideas for the project of calculator
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 Calculator program - Java Beginners
Java Calculator program  import java.awt.*; import javax.swing.*; import java.awt.event.*; class Calculator implements ActionListener { int c,n...://www.roseindia.net/java/example/java/swing/calculator-in-swing.shtml Hope
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
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... of Calculator program in Java package Tutorial; import java.io.*; class
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 Applet   How to add Image in Java Applet? what is getDocumentBase
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
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
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  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
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
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
 

 

 

DMCA.com