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);

            }

    }

Edited 3 Years Ago by Reverend Jim: Fixed formatting

cannot find symbol
symbol : variable Total

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

This article has been dead for over six months. Start a new discussion instead.