11 Replies - 916 Views - Last Post: 08 November 2011 - 08:50 PM Rate Topic: -----

#1 ali11   User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 55
  • Joined: 25-October 11

need help to fix my codes.

Posted 08 November 2011 - 01:10 PM

I am getting some errors I just don't know how to fix them.errors I am getting are written below.

import java.util.Stack;
import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import javax.swing.event.*;
import java.util.Scanner;


public class CalcGUIPanel extends JPanel
{

//=============================================== instance variables private JTextField displayField; // display result / input.

 //--\- Variables representing state of the calculator

 private boolean startNumber = true; // true: num key next

 private int resultValue = 0; // result so far

 private String previousOp = "="; // previous operation

 Stack<String> cStack=new Stack<String>();

 public CalcGUIPanel()
 {

 //--\- Display field

 displayField = new JTextField();

JButton clearButton = new JButton("CLEAR");

clearButton.setFont(BIGGER_FONT);

clearButton.addActionListener(new ClearListener());



 //--\- One listener for all numeric keys.

 ActionListener numListener = new NumListener();

 //--\- Layout numeric keys in a grid. Generate the buttons

 // in a loop from the chars in a string.

 String buttonOrder = "789456123 0 ";

 JPanel buttonPanel = new JPanel(new GridLayout(5, 3));

 for (int i = 0; i < buttonOrder.length(); i++) {
 {
cStack.push(buttonOrder[i]);
}


 String keyTop = buttonOrder.substring(i, i+1);

 if (keyTop.equals(" ")) {

 buttonPanel.add(new JLabel(""));

 } else {

 JButton b = new JButton(keyTop);

 b.addActionListener(numListener);


 b.setFont(BIGGER_FONT);

 buttonPanel.add(B)/>;

 }

 }


 //--\- One ActionListener to use for all operator buttons.

 ActionListener opListener = new OpListener();

 //--\- Create panel with gridlayout to hold operator buttons.

 // Use array of button names to create buttons in a loop.

 JPanel opPanel = new JPanel(new GridLayout(5, 1));

 String[] opOrder = {"+", "-", "*", "/", "enter"};

 for (int i = 0; i < opOrder.length; i++) {

 JButton b = new JButton(opOrder[i]);
  {

 cStack.push(opOrder[i]);
 		 }



 b.addActionListener(opListener);

c.push("1");
c.push("2");
c.push("3");
c.push("4");
c.push("5");
c.push("6");
c.push("7");
c.push("8");
c.push("9");
c.push("0");
 c.push("+");
  c.push("-");
  c.push("*");
  c.push("/");
  c.push("enter");


 b.setFont(BIGGER_FONT);

 opPanel.add(B)/>;

 }

 //--\- Layout the top-level panel.

 this.setLayout(new BorderLayout());

 this.add(displayField, BorderLayout.NORTH );

 this.add(buttonPanel , BorderLayout.CENTER);

 this.add(opPanel , BorderLayout.EAST );

this.add(clearButton , BorderLayout.SOUTH );

 }//end constructor

 //====================================================== action_clear

 /*\* Called by Clear btn action listener and elsewhere.*/

 private void action_clear() {

 startNumber = true;

 displayField.setText("0");

 resultValue = 0;

 previousOp = "=";

 }

 // inner listener class OpListener

 /*\* Listener for all op buttons. \*/

 class OpListener implements ActionListener {

 public void actionPerformed(ActionEvent e) {

 // The calculator is always in one of two states.

 // 1. A number must be entered \-\- this operator is wrong.

 // 2. An operator must be entered \-\- we're ok.
 if (startNumber) { // Error: needed number, not operator

 action_clear();

 displayField.setText("ERROR");

 } else {



 startNumber = true; // Next thing must be a number


try {

 String displayText = displayField.getText();

 int currentValue = Integer.parseInt(displayText);


 if (previousOp.equals("=")) {
 cStack.push(resultValue + "");



 resultValue = currentValue;

 }

  else if (previousOp.equals("+")) {
	  cStack.pop().equals("+");


 BigInteger resultValue = new BigInteger(cStack.pop());
 BigInteger currentValue = new Biginteger(cStack.pop());

 resultValue += currentValue;
 cStack.push(resultValue + "");


 }  else if (previousOp.equals("-")) {
	  cStack.pop().equals("-");

		 BigInteger resultValue = new BigInteger(cStack.pop());
		 BigInteger currentValue = new BigInteger(cStack.pop());

 resultValue -= currentValue;
 cStack.push(resultValue + "");


 } else if (previousOp.equals("*")) {
	cStack.pop().equals("*");

			 BigInteger resultValue = new BigInteger(cStack.pop());
			 BigInteger currentValue = new BigInteger(cStack.pop());


 resultValue *= currentValue;
 cStack.push(resultValue + "");


 } else if (previousOp.equals("/")) {
	cStack.pop().equals("/");

		 BigInteger resultValue = new BigInteger(cStack.pop());
			 BigInteger currentValue = new BigInteger(cStack.pop());
 resultValue /= currentValue;
 cStack.push(resultValue + "");

 }

 displayField.setText("" + resultValue);
 } catch (NumberFormatException ex) {

 action_clear();

 displayField.setText("Error");

}


 //--\- set \_previousOp for the next operator.

 previousOp = e.getActionCommand();

 }//endif \_startNumber

 }//endmethod

 }//end class

 //////////////////////////////////// inner listener class ClearListener

 // Action listener for numeric keys

 class NumListener implements ActionListener {

 public void actionPerformed(ActionEvent e) {

 String digit = e.getActionCommand(); // Get text from button

 if (startNumber) {

 // This is the first digit, clear field and set

 displayField.setText(digit);

 startNumber = false;

 } else {

 // Add this digit to the end of the display field

 displayField.setText(displayField.getText() + digit);

 }

 }

 }//end class

 //inner listener class ClearListener

class ClearListener implements ActionListener {

public void actionPerformed(ActionEvent e) {

action_clear();
}
}
}













C:\Users\Hamza\Pictures\CalcGUIPanel.java:43: cannot find symbol
symbol : variable BIGGER_FONT
location: class CalcGUIPanel
clearButton.setFont(BIGGER_FONT);
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:63: array required, but java.lang.String found
cStack.push(buttonOrder[i]);
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:80: cannot find symbol
symbol : variable BIGGER_FONT
location: class CalcGUIPanel
b.setFont(BIGGER_FONT);
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:123: non-static method push(E) cannot be referenced from a static context
Stack.push("+");
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:127: cannot find symbol
symbol : variable cStacl
location: class CalcGUIPanel
cStacl.push("enter");
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:130: cannot find symbol
symbol : variable BIGGER_FONT
location: class CalcGUIPanel
b.setFont(BIGGER_FONT);
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:212: cannot find symbol
symbol : class BigInteger
location: class CalcGUIPanel.OpListener
BigInteger resultValue = new BigInteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:212: cannot find symbol
symbol : class BigInteger
location: class CalcGUIPanel.OpListener
BigInteger resultValue = new BigInteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:213: cannot find symbol
symbol : class BigInteger
location: class CalcGUIPanel.OpListener
BigInteger currentValue = new Biginteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:213: currentValue is already defined in actionPerformed(java.awt.event.ActionEvent)
BigInteger currentValue = new Biginteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:213: cannot find symbol
symbol : class Biginteger
location: class CalcGUIPanel.OpListener
BigInteger currentValue = new Biginteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:222: cannot find symbol
symbol : class BigInteger
location: class CalcGUIPanel.OpListener
BigInteger resultValue = new BigInteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:222: cannot find symbol
symbol : class BigInteger
location: class CalcGUIPanel.OpListener
BigInteger resultValue = new BigInteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:223: cannot find symbol
symbol : class BigInteger
location: class CalcGUIPanel.OpListener
BigInteger currentValue = new BigInteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:223: currentValue is already defined in actionPerformed(java.awt.event.ActionEvent)
BigInteger currentValue = new BigInteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:223: cannot find symbol
symbol : class BigInteger
location: class CalcGUIPanel.OpListener
BigInteger currentValue = new BigInteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:232: cannot find symbol
symbol : class BigInteger
location: class CalcGUIPanel.OpListener
BigInteger resultValue = new BigInteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:232: cannot find symbol
symbol : class BigInteger
location: class CalcGUIPanel.OpListener
BigInteger resultValue = new BigInteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:233: cannot find symbol
symbol : class BigInteger
location: class CalcGUIPanel.OpListener
BigInteger currentValue = new BigInteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:233: currentValue is already defined in actionPerformed(java.awt.event.ActionEvent)
BigInteger currentValue = new BigInteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:233: cannot find symbol
symbol : class BigInteger
location: class CalcGUIPanel.OpListener
BigInteger currentValue = new BigInteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:243: cannot find symbol
symbol : class BigInteger
location: class CalcGUIPanel.OpListener
BigInteger resultValue = new BigInteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:243: cannot find symbol
symbol : class BigInteger
location: class CalcGUIPanel.OpListener
BigInteger resultValue = new BigInteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:244: cannot find symbol
symbol : class BigInteger
location: class CalcGUIPanel.OpListener
BigInteger currentValue = new BigInteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:244: currentValue is already defined in actionPerformed(java.awt.event.ActionEvent)
BigInteger currentValue = new BigInteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:244: cannot find symbol
symbol : class BigInteger
location: class CalcGUIPanel.OpListener
BigInteger currentValue = new BigInteger(cStack.pop());
^
Note: C:\Users\Hamza\Pictures\CalcGUIPanel.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
26 errors

Tool completed with exit code 1

Is This A Good Question/Topic? 0
  • +

Replies To: need help to fix my codes.

#2 DarenR   User is offline

  • D.I.C Lover

Reputation: 593
  • View blog
  • Posts: 3,823
  • Joined: 12-January 10

Re: need help to fix my codes.

Posted 08 November 2011 - 01:20 PM

did you declare those variables before using them? I noticed the 1st one Bigger_Font isn't declared---I will assume it may be true of the rest since I didn't go through your entire code.
Was This Post Helpful? 0
  • +
  • -

#3 Martyr2   User is offline

  • Programming Theoretician
  • member icon

Reputation: 5225
  • View blog
  • Posts: 14,005
  • Joined: 18-April 07

Re: need help to fix my codes.

Posted 08 November 2011 - 01:22 PM

I think you forgot to import java.math.BigInteger at the top. You need this if you wish to use the BigInteger class in your program.

Also, where do you define BIGGER_FONT as having a value? You might want to say what BIGGER_FONT means before you attempt to use it.

Fix these two things will knock out a slew of errors and then repost the error list again so we can see where to go from there.
Was This Post Helpful? 0
  • +
  • -

#4 jon.kiparsky   User is offline

  • Beginner
  • member icon


Reputation: 11069
  • View blog
  • Posts: 18,907
  • Joined: 19-March 11

Re: need help to fix my codes.

Posted 08 November 2011 - 01:23 PM

C:\Users\Hamza\Pictures\CalcGUIPanel.java:43: cannot find symbol

"Cannot find symbol" means the compiler believes you've referred to a symbol - a variable, or a class, or a method, something user-defined - which doesn't exist. Either you've mis-typed a name, or you're referring to something which is not visible in the current scope. The error is on line 43 of CalcGUIPanel.java.

C:\Users\Hamza\Pictures\CalcGUIPanel.java:63: array required, but java.lang.String found

This means exactly what it says: you've tried to put a String into a context where the compiler expects an array, and the error is on line 63 of CalcGUIPanel.java.

C:\Users\Hamza\Pictures\CalcGUIPanel.java:123: non-static method push(E) cannot be referenced from a static context

A static method (like main()) cannot reference an instance method. You have to either make the method static or create an object to run this method from.

C:\Users\Hamza\Pictures\CalcGUIPanel.java:213: currentValue is already defined in actionPerformed(java.awt.event.ActionEvent)

This is telling you that you've already defined this variable in this context.


Note: C:\Users\Hamza\Pictures\CalcGUIPanel.java uses unchecked or unsafe operations.

This you can ignore for now.
Was This Post Helpful? 0
  • +
  • -

#5 ali11   User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 55
  • Joined: 25-October 11

Re: need help to fix my codes.

Posted 08 November 2011 - 02:20 PM

View PostMartyr2, on 08 November 2011 - 01:22 PM, said:

I think you forgot to import java.math.BigInteger at the top. You need this if you wish to use the BigInteger class in your program.

Also, where do you define BIGGER_FONT as having a value? You might want to say what BIGGER_FONT means before you attempt to use it.

Fix these two things will knock out a slew of errors and then repost the error list again so we can see where to go from there.


Ok these are my errors after I fix my codes.can you also look if I did stack right.I am creating RPN calculator.
C:\Users\Hamza\Pictures\CalcGUIPanel.java:236: illegal start of expression
resultValue * = currentValue;
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:245: illegal start of expression
resultValue / = currentValue;
^
2 errors

Tool completed with exit code 1
Was This Post Helpful? 0
  • +
  • -

#6 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8378
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: need help to fix my codes.

Posted 08 November 2011 - 02:24 PM

There si no space between the * or the / and the =
Was This Post Helpful? 0
  • +
  • -

#7 ali11   User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 55
  • Joined: 25-October 11

Re: need help to fix my codes.

Posted 08 November 2011 - 02:33 PM

View Postpbl, on 08 November 2011 - 02:24 PM, said:

There si no space between the * or the / and the =

but how can i fix these codes
C:\Users\Hamza\Pictures\CalcGUIPanel.java:63: array required, but java.lang.String found
cStack.push(buttonOrder[i]);
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:213: currentValue is already defined in actionPerformed(java.awt.event.ActionEvent)
BigInteger currentValue = new Biginteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:213: cannot find symbol
symbol : class Biginteger
location: class CalcGUIPanel.OpListener
BigInteger currentValue = new Biginteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:215: operator + cannot be applied to java.math.BigInteger,java.math.BigInteger
resultValue += currentValue;
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:223: currentValue is already defined in actionPerformed(java.awt.event.ActionEvent)
BigInteger currentValue = new BigInteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:225: operator - cannot be applied to java.math.BigInteger,java.math.BigInteger
resultValue -= currentValue;
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:233: currentValue is already defined in actionPerformed(java.awt.event.ActionEvent)
BigInteger currentValue = new BigInteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:236: operator * cannot be applied to java.math.BigInteger,java.math.BigInteger
resultValue *= currentValue;
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:244: currentValue is already defined in actionPerformed(java.awt.event.ActionEvent)
BigInteger currentValue = new BigInteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:245: operator / cannot be applied to java.math.BigInteger,java.math.BigInteger
resultValue /= currentValue;
^
10 errors

Tool completed with exit code 1
Was This Post Helpful? 0
  • +
  • -

#8 ali11   User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 55
  • Joined: 25-October 11

Re: need help to fix my codes.

Posted 08 November 2011 - 02:54 PM

I just update my codes

import java.util.Stack;
import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import javax.swing.event.*;
import java.util.Scanner;
import java.math.BigInteger;

public class CalcGUIPanel extends JPanel
{




 //=============================================== instance variables

 //--\- Component referenced during execution

 private JTextField displayField; // display result / input.

 //--\- Variables representing state of the calculator

 private boolean startNumber = true; // true: num key next

 private int resultValue = 0; // result so far

 private String previousOp = "="; // previous operation

 Stack<String> cStack=new Stack<String>();

 public CalcGUIPanel()
 {

 //--\- Display field

 displayField = new JTextField();

JButton clearButton = new JButton("CLEAR");



clearButton.addActionListener(new ClearListener());



 //--\- One listener for all numeric keys.

 ActionListener numListener = new NumListener();

 //--\- Layout numeric keys in a grid. Generate the buttons

 // in a loop from the chars in a string.

 String buttonOrder = "789456123 0 ";

 JPanel buttonPanel = new JPanel(new GridLayout(5, 3));

 for (int i = 0; i < buttonOrder.length(); i++) {
 {
cStack.push(buttonOrder[i]);
}


 String keyTop = buttonOrder.substring(i, i+1);

 if (keyTop.equals(" ")) {

 buttonPanel.add(new JLabel(""));

 } else {

 JButton b = new JButton(keyTop);

 b.addActionListener(numListener);




 buttonPanel.add(B)/>;

 }

 }


 //--\- One ActionListener to use for all operator buttons.

 ActionListener opListener = new OpListener();

 //--\- Create panel with gridlayout to hold operator buttons.

 // Use array of button names to create buttons in a loop.

 JPanel opPanel = new JPanel(new GridLayout(5, 1));

 String[] opOrder = {"+", "-", "*", "/", "enter"};

 for (int i = 0; i < opOrder.length; i++) {

 JButton b = new JButton(opOrder[i]);
  {

 cStack.push(opOrder[i]);
 		 }



 b.addActionListener(opListener);

cStack.push("1");
cStack.push("2");
cStack.push("3");
cStack.push("4");
cStack.push("5");
cStack.push("6");
cStack.push("7");
cStack.push("8");
cStack.push("9");
cStack.push("0");
 cStack.push("+");
  cStack.push("-");
  cStack.push("*");
  cStack.push("/");
  cStack.push("enter");




 opPanel.add(B)/>;

 }

 //--\- Layout the top-level panel.

 this.setLayout(new BorderLayout());

 this.add(displayField, BorderLayout.NORTH );

 this.add(buttonPanel , BorderLayout.CENTER);

 this.add(opPanel , BorderLayout.EAST );

this.add(clearButton , BorderLayout.SOUTH );

 }//end constructor

 //====================================================== action_clear

 /*\* Called by Clear btn action listener and elsewhere.*/

 private void action_clear() {

 startNumber = true;

 displayField.setText("0");

 resultValue = 0;

 previousOp = "=";

 }

 // inner listener class OpListener

 /*\* Listener for all op buttons. \*/

 class OpListener implements ActionListener {

 public void actionPerformed(ActionEvent e) {

 // The calculator is always in one of two states.

 // 1. A number must be entered \-\- this operator is wrong.

 // 2. An operator must be entered \-\- we're ok.
 if (startNumber) { // Error: needed number, not operator

 action_clear();

 displayField.setText("ERROR");

 } else {



 startNumber = true; // Next thing must be a number


try {

 String displayText = displayField.getText();

 int currentValue = Integer.parseInt(displayText);


 if (previousOp.equals("=")) {
 cStack.push(resultValue + "");



 resultValue = currentValue;

 }

  else if (previousOp.equals("+")) {
	  cStack.pop().equals("+");


 BigInteger resultValue = new BigInteger(cStack.pop());
 BigInteger currentValue = new Biginteger(cStack.pop());

 resultValue += currentValue;
 cStack.push(resultValue + "");


 }  else if (previousOp.equals("-")) {
	  cStack.pop().equals("-");

		 BigInteger resultValue = new BigInteger(cStack.pop());
		 BigInteger currentValue = new BigInteger(cStack.pop());

 resultValue -= currentValue;
 cStack.push(resultValue + "");


 } else if (previousOp.equals("*")) {
	cStack.pop().equals("*");

			 BigInteger resultValue = new BigInteger(cStack.pop());
			 BigInteger currentValue = new BigInteger(cStack.pop());


 resultValue *= currentValue;
 cStack.push(resultValue + "");


 } else if (previousOp.equals("/")) {
	cStack.pop().equals("/");

		 BigInteger resultValue = new BigInteger(cStack.pop());
			 BigInteger currentValue = new BigInteger(cStack.pop());
 resultValue /= currentValue;
 cStack.push(resultValue + "");

 }

 displayField.setText("" + resultValue);
 } catch (NumberFormatException ex) {

 action_clear();

 displayField.setText("Error");

}


 //--\- set \_previousOp for the next operator.

 previousOp = e.getActionCommand();

 }//endif \_startNumber

 }//endmethod

 }//end class

 //////////////////////////////////// inner listener class ClearListener

 // Action listener for numeric keys

 class NumListener implements ActionListener {

 public void actionPerformed(ActionEvent e) {

 String digit = e.getActionCommand(); // Get text from button

 if (startNumber) {

 // This is the first digit, clear field and set

 displayField.setText(digit);

 startNumber = false;

 } else {

 // Add this digit to the end of the display field

 displayField.setText(displayField.getText() + digit);

 }

 }

 }//end class

 //inner listener class ClearListener

class ClearListener implements ActionListener {

public void actionPerformed(ActionEvent e) {

action_clear();
}
}
}






These r errors i am getting.Plz also look at my stack.

C:\Users\Hamza\Pictures\CalcGUIPanel.java:63: array required, but java.lang.String found
cStack.push(buttonOrder[i]);
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:213: currentValue is already defined in actionPerformed(java.awt.event.ActionEvent)
BigInteger currentValue = new Biginteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:213: cannot find symbol
symbol : class Biginteger
location: class CalcGUIPanel.OpListener
BigInteger currentValue = new Biginteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:215: operator + cannot be applied to java.math.BigInteger,java.math.BigInteger
resultValue += currentValue;
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:223: currentValue is already defined in actionPerformed(java.awt.event.ActionEvent)
BigInteger currentValue = new BigInteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:225: operator - cannot be applied to java.math.BigInteger,java.math.BigInteger
resultValue -= currentValue;
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:233: currentValue is already defined in actionPerformed(java.awt.event.ActionEvent)
BigInteger currentValue = new BigInteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:236: operator * cannot be applied to java.math.BigInteger,java.math.BigInteger
resultValue *= currentValue;
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:244: currentValue is already defined in actionPerformed(java.awt.event.ActionEvent)
BigInteger currentValue = new BigInteger(cStack.pop());
^
C:\Users\Hamza\Pictures\CalcGUIPanel.java:245: operator / cannot be applied to java.math.BigInteger,java.math.BigInteger
resultValue /= currentValue;
^
10 errors

Tool completed with exit code 1
Was This Post Helpful? 0
  • +
  • -

#9 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8378
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: need help to fix my codes.

Posted 08 November 2011 - 06:43 PM

Biginteger is BigInteger
that would fix a few

You cannot apply the basic operators +-/* to BigInteger objects
That will fix another bunch
Was This Post Helpful? 0
  • +
  • -

#10 ali11   User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 55
  • Joined: 25-October 11

Re: need help to fix my codes.

Posted 08 November 2011 - 07:01 PM

View Postpbl, on 08 November 2011 - 06:43 PM, said:

Biginteger is BigInteger
that would fix a few

You cannot apply the basic operators +-/* to BigInteger objects
That will fix another bunch

so I have to remove Big Integer
Was This Post Helpful? 0
  • +
  • -

#11 jon.kiparsky   User is offline

  • Beginner
  • member icon


Reputation: 11069
  • View blog
  • Posts: 18,907
  • Joined: 19-March 11

Re: need help to fix my codes.

Posted 08 November 2011 - 08:12 PM

View Postali11, on 08 November 2011 - 09:01 PM, said:

so I have to remove Big Integer



No, you have to learn how to use it.
Was This Post Helpful? 0
  • +
  • -

#12 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8378
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: need help to fix my codes.

Posted 08 November 2011 - 08:50 PM

View Postpbl, on 08 November 2011 - 09:43 PM, said:

Biginteger is BigInteger
that would fix a few

You cannot apply the basic operators +-/* to BigInteger objects
That will fix another bunch

Actually Java does not, compared to C++, support the +-/* operators for all objects but the + for String. A very usefull exception where the compiler cheats and used a StringBuffer to concatenate the Strings

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1