473,394 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 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 6629
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.