Hi am creating a simple Java calculator and I keep getting the error: DylCalc.java:21: cannot find symbol
symbol : variable Total
location: class DylCalc

        JOptionPane.showMessageDialog(null,value1+" - "+value2+ "="+Total); 
                                                                    ^

Here is my code is anyone has any Ideas:

import javax.swing.JOptionPane;

/** This program is a simple Addition, Subtraction, Multiplication and Division Calculator.
*/

public class DylCalc
{
public static void main(String[] args)
    {
    int value1=0, value2=0;
    JOptionPane.showMessageDialog(null, "Let's do some math!");

    String temp1 = JOptionPane.showInputDialog(null,"Please enter first value.");
        value1=Integer.parseInt(temp1);


    String temp2 = JOptionPane.showInputDialog(null,"Please enter second value.");                                                                                              value2=Integer.parseInt(temp2);


        JOptionPane.showMessageDialog(null,value1+" - "+value2+ " = " +Total); 
        JOptionPane.showMessageDialog(null,value1+" + "+value2+ " = " +Total);
        JOptionPane.showMessageDialog(null,value1+" * "+value2+ " = " +Total);
        JOptionPane.showMessageDialog(null,value1+" / "+value2+ " = " +Total);      
            JOptionPane.showMessageDialog(null,value1+" % "+value2+ " = " +Total);

            }

    }

Recommended Answers

All 2 Replies

cannot find symbol
symbol : variable Total

The error message says it all: The compile can NOT find a definition for the variable: Total.

Yes Total is not delcared

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.