0

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 by Reverend Jim: Fixed formatting

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Victor C.
0

cannot find symbol
symbol : variable Total

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.