472,802 Members | 1,435 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,802 software developers and data experts.

getting cannot find symbol

I'm having 4 errors, I'm very new at this and I would appreciate your input. The error I get is:
Week5MortgageGUI.java:151:cannot find symbol
symbol: method allInterest(double,double,double)
Location: class Week5MortgageGUI
Week5MortgageLogic allint = logic.allInterest(amount, term[x], rate[x]);


Week5MortgageGUI.java:152:cannot find symbol
symbol: method allInterest(double,double,double)
Location: class Week5MortgageGUI
textarea.append(logic.calculateMortgage(amount, term[x], rate[x]));

Week5MortgageGUI.java:156:cannot find symbol
symbol: class ApplePie
Location: class Week5MortgageGUI
pie = new ApplePie(2);

Week5MortgageGUI.java:157:cannot find symbol
symbol: method addSlice(java.awt.Color,double)
Location: class java.awt.event.ActionEvent
pie.addSlice(Color.red, allint);
^
Week5MortgageGUI.java:158:cannot find symbol
symbol: method addSlice(java.awt.Color,double)
Location: class java.awt.event.ActionEvent
pie.addSlice(Color.green, amount);
^
Week5MortgageGUI.java:160:cannot find symbol
symbol: method addSlice(java.awt.Color,double)
Location: class java.awt.Container
jpie.getContentPane().add(pie);
^

This is the code that is getting the error. Can anyone help me out? =)

[PHP]import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.text.DecimalFormat;
import java.net.URL;
import java.awt.event.ActionEvent;


public class Week5MortgageGUI extends JApplet implements ActionListener {

//Declare variables and arrays
int x;
double amount, allint;
String header = ("MONTH \tPAYMENT \tBALANCE \tINTEREST \n");
String[] cases = new String[4];//Empty array
double[] rate = new double[4];//Empty array
double[] term = {7, 15, 30, 0};
DecimalFormat money = new DecimalFormat("$###,###.00");//New DecimalFormat object named 'money'
//Set up JFrame GUI components
JButton cal = new JButton("Calculate!");
JButton ok = new JButton("Ok");
JButton quit = new JButton("Quit");
JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
JPanel panel3 = new JPanel();
JPanel panel4 = new JPanel();
Box box1 = Box.createVerticalBox();
Box box2 = Box.createVerticalBox();
Box myBox = Box.createVerticalBox();
JLabel select = new JLabel("Select loan term & rate:");
JLabel amountlabel = new JLabel("Enter Amount: $");//Create label that directs user to enter his/her name
JLabel termlabel = new JLabel("Enter Term: ");//Create label that directs user to enter his/her name
JLabel ratelabel = new JLabel("Enter Rate: ");//Create label that directs user to enter his/her name
JLabel message = new JLabel("Click Ok to continue:");
JLabel legend = new JLabel("Pie Chart Legend:");
JLabel space = new JLabel("-------------------------");
JLabel allinterest;
JLabel allprincipal;
JTextField amounttext = new JTextField(10);//Create blank text field
JTextField termtext = new JTextField(10);//Create blank text field
JTextField ratetext = new JTextField(10);//Create blank text field
JTextArea textarea = new JTextArea(8, 35);
JScrollPane scroll = new JScrollPane(textarea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
JRadioButton radio1 = new JRadioButton();
JRadioButton radio2 = new JRadioButton();
JRadioButton radio3 = new JRadioButton();
JRadioButton radio4 = new JRadioButton();
ButtonGroup group = new ButtonGroup();
Container content_pane = getContentPane();
JFrame jpie;

//Declare init() method for JApplet
public void init() {
setSize(600, 400);//Set JApplet size
FlowLayout flow = new FlowLayout();//Create FlowLayout object called 'nameflow'
content_pane.setLayout(flow);//Set content_pane layout format to 'flow' object
this.readRates("rates.txt");//Populate 'rate' array from the values contained within file "rates.txt" - see method below
cases[0] = "7 year at " + rate[0] + "%";//Populate 'cases' array
cases[1] = "15 year at " + rate[1] + "%";
cases[2] = "30 year at " + rate[2] + "%";
cases[3] = "Enter my own term & rate";
radio1.setText(cases[0]);//Set up radio buttons
radio2.setText(cases[1]);
radio3.setText(cases[2]);
radio4.setText(cases[3]);
amounttext.addActionListener(this);//Add the action listeners
termtext.addActionListener(this);
ratetext.addActionListener(this);
cal.addActionListener(this);
ok.addActionListener(this);
quit.addActionListener(this);
radio1.addActionListener(this);
radio2.addActionListener(this);
radio3.addActionListener(this);
radio4.addActionListener(this);
group.add(radio1);//Add radio buttons to button group
group.add(radio2);
group.add(radio3);
group.add(radio4);
box1.add(select);//Add radio buttons to vertical box #1
box1.add(radio1);
box1.add(radio2);
box1.add(radio3);
box1.add(radio4);
box2.add(termlabel);//Add these GUI components to vertical box #2
box2.add(termtext);
box2.add(ratelabel);
box2.add(ratetext);
panel1.add(amountlabel);//Add GUI components to panel #1
panel1.add(amounttext);
panel1.add(box1);
panel2.add(cal);//Add GUI components to panel #2
panel3.add(scroll);//Add GUI components to panel #3
content_pane.add(panel1);//Add these panels to the content pane
content_pane.add(panel2);
content_pane.add(panel3);
textarea.append(header);
panel4.add(message);//Add GUI components to panel #4 but don't add panel to content pane yet
panel4.add(ok);
panel4.add(quit);
this.setVisible(true);//Make the JFrame visible to the user
}


//Declare actionPerformed method to receive & process ActionListener event (user input)
public void actionPerformed(ActionEvent response) {
Object rspname = response.getSource();//Get response source

try {
//Rearrange display to accept user-defined term & rate if radio4 is selected
if (radio4.isSelected() == true) {
panel1.add(box2);
content_pane.validate();
}
//Remove text labels & fields for user-defined term & rate if radio4 is not selected
if (radio4.isSelected() == false) {
panel1.remove(box2);
content_pane.validate();
}

if (rspname == cal) {
//Obtain user-defined term & rate from termtext & ratetext fields
if (rspname == cal && radio4.isSelected() == true) {
term[3] = Double.parseDouble(termtext.getText());//Parse double from String
rate[3] = Double.parseDouble(ratetext.getText());
x = 3;
}
if (rspname == cal && radio3.isSelected() == true) {
x = 2;
}
if (rspname == cal && radio2.isSelected() == true) {
x = 1;
}
if (rspname == cal && radio1.isSelected() == true) {
x = 0;
}
//Throw this special Exception if the user fails to make a selection
if (radio1.isSelected() == false && radio2.isSelected() == false && radio3.isSelected() == false && radio4.isSelected() == false) {
throw new Exception("SelectionError");
}
amount = Double.parseDouble(amounttext.getText());//pull amount data from amounttext field
Week5MortgageGUI logic = new Week5MortgageGUI();
allint = logic.allInterest(amount, term[x], rate[x]);//Calculate total interest paid over life of loan.
textarea.append(logic.calculateMortgage(amount, term[x], rate[x]));//Obtain the amortization table from the logic class

ActionEvent pie ;

pie = new ApplePie(2);//Create ApplePie object (pie chart)
pie.addSlice(Color.red, allint);//Red pie slice = allint value
pie.addSlice(Color.green, amount);//Green pie slice = amount value
jpie = new JFrame("Interest vs. Principal");//Create JFrame to hold pie chart
jpie.getContentPane().add(pie);//Add pie chart to JFrame
jpie.pack();//Causes this Window to be sized to fit the preferred size and layouts of its subcomponents.
jpie.setSize(250, 250);//Set size of new JFrame window
jpie.setVisible(true);//Make the JFrame visible to the user

allinterest = new JLabel("RED - Total interest paid: " + money.format(allint));//Pie labels
allprincipal = new JLabel("GREEN - Total principal paid: " + money.format(amount));//Pie labels
myBox.add(legend);//Add labels to vertical box
myBox.add(space);
myBox.add(allinterest);
myBox.add(allprincipal);
content_pane.add(myBox);//Add vertical box to content pane
content_pane.add(panel4);//Add panel4 to content pane
content_pane.validate();//Refresh the JPanel
}

if (rspname == quit) {//Selecting Quit disposes of the jpie & current JFrame
jpie.dispose();
jpie.setVisible(false);//Set visible-false to avoid memory leaks
this.setVisible(false);
}

if (rspname == ok) {//Selecting Ok clears the populated fields
jpie.dispose();//Dispose of the jpie JFrame
jpie.setVisible(false);//Set visible-false to avoid memory leaks
textarea.setText("");
amounttext.setText("");
termtext.setText("");
ratetext.setText("");
this.remove(myBox);
this.repaint();
this.validate();
myBox.remove(legend);
myBox.remove(space);
myBox.remove(allinterest);
myBox.remove(allprincipal);
myBox.revalidate();
}
} //Take these actions when an Exception occurs
catch (NumberFormatException e)//Specific Exception
{
textarea.append("Invalid Entry - The amount must be a positive number!\n" + e.toString() + "\n");
} catch (Exception e)//More general exception
{
if (e.getMessage() == "SelectionError") {//Specify exception message
textarea.append("Invalid Entry - Please select term & rate of your loan\n" + e.toString() + "\n");
} else {//Other general exceptions
textarea.append("Invalid Entry - The amount must be a positive number!\n" + e.toString() + "\n");
}
} catch (Throwable e)//Catch everything else
{
textarea.append("Invalid Entry!\n" + e.toString() + "\n");
}

}


private void readRates(String filename) {
try {
URL codeBase = getCodeBase();
URL url = null;
int index = 0;
url = new URL(codeBase, filename);
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
String line = reader.readLine();
while (line != null) {
rate[index] = Double.parseDouble(line);
line = reader.readLine();
index++;
}
} catch (Exception e) {
textarea.append("Could not read from file " + filename);
}
}

//Create an instance of the Week5MortgageGUI (this) class
public static void main(String[] args,Week5MortgageGUI Week5MortgageGUI) {
Week5MortgageGUI = new Week5MortgageGUI();
}


}
[/PHP]
Feb 15 '08 #1
2 6538
Can anyone please help me? I would really appreciate it!
Feb 15 '08 #2
BigDaddyLH
1,216 Expert 1GB
I'm having 4 errors, I'm very new at this and I would appreciate your input. The error I get is:
Week5MortgageGUI.java:151:cannot find symbol
symbol: method allInterest(double,double,double)
Location: class Week5MortgageGUI
Week5MortgageLogic allint = logic.allInterest(amount, term[x], rate[x]);
That error says it all. You wrote:
Expand|Select|Wrap|Line Numbers
  1. Week5MortgageGUI logic = new Week5MortgageGUI();
  2. allint = logic.allInterest(amount, term[x], rate[x]);
  3.  
That line only makes sense if class Week5MortageLogic had a method named allInterest, which it doesn't.

What did you think that line was going to do? Also, Week5MortageLogic is an applet, and you are instantiating the class within its init method, which doesn't make any sense, or am I missing something?
Feb 15 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
15
by: Bjorn Jensen | last post by:
Hi! An beginner question: Pleas help me with this (-: Error (the arrow points on the s in sqrt) ===== tal.java:6: cannot find symbol symbol : method sqrt(int) location: class tal...
1
by: vsp15584 | last post by:
Hii..i use the coding as below :- import java.applet.applet; import java.awt.*; import com.sun.j3d.utils.applet.mainframe; import com.sun.j3d.utils.universe.*; import...
2
by: cazconv2007 | last post by:
i cant understand why it says cannot find symbol can you guys look thanx i can get it to show john doe but not my next name. class Name { public String firstName ="carl"; private...
3
oll3i
by: oll3i | last post by:
i m trying to write a hello world server but i get the following 3 errors cd u please help me javac HelloServer.java HelloApp/*.java HelloServer.java:52: cannot find symbol symbol: class...
4
by: jingchua | last post by:
Hi, can anyone help out here???? I have the below error after compling the file. Any idea what is wrong in the declaration that was done in the above code??? Appreciate any help on shedding some...
2
by: jazzyme2 | last post by:
New to Java. Working on this and ran into this problem. Any clues? java:42: cannot find symbol symbol : constructor Pay() location: class Pay Pay Emp1 = new Pay(); ^ 43:...
10
by: CodeNoob | last post by:
please help been working on a project got it down to 5 errors from 100 now i have no idea what to do. Errors: init: deps-jar: Created dir: C:\Users\Tommy\Desktop\build\classes Compiling 306...
3
by: Sindhu Rani | last post by:
i hav created 3 classes in 3 different files. am gettin an error durin compilation. wat shud i do??? C:\s\source>javac -d ..\classes devtestdrive.java devtestdrive.java:5: cannot resolve symbol...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.