Results 1 to 3 of 3
  1. #1
    laurenceshan is offline Member
    Join Date
    Sep 2012
    Posts
    1
    Rep Power
    0

    Default Error symbol not found Please help

    hi guys im new to java and having real troubles with a program that im trying code everytime i compile it i get symbol not found error?
    maybe somebody can explain this to me.

    the coding is below:






    import javax.swing.*;
    import it.*;
    import java.awt.*;

    public class RedBlue
    {
    public static void main(String [] args)
    {
    int points = 0;
    int first = 0;
    int secon = 0;

    while(points>=0&&points<=50)
    {
    inputColour();
    }
    System.out.println
    ("Your score was "+points);
    if(points>=50)
    {
    System.out.println
    ("You won");
    }
    else
    {
    System.out.println
    ("You lose");
    }
    }


    static void inputColour()
    {
    int comp = (int)((Math.random()*2)+1);
    int user = Integer.parseInt(JOptionpane.showInputDialog
    ("Enter 1 for Red or 2 for Blue"));
    if(comp == user)
    {
    points = points+20;
    }
    else
    {
    points = points+20;
    }

    if(user==1)
    {
    red();
    }
    else
    {
    if(user==2)
    {
    blue();
    }
    else
    {
    JOptionPane.showMessageDialog(null,
    "Enter 1 for Red or 2 for Blue");
    }
    }
    }

    static void red()
    {
    first = (int)((Math.random()*10)+1);
    secon = (int)((Math.random()*10)+1);

    ans = Integer.parseInt(JOptionPane.showInputDialog
    (first+secon+", "+first+secon+secon+", "+first+
    secon+secon+secon+"... what is the fourth term?"));

    if(ans==(first+(secon*4)))
    {
    points = points+5;
    JOptionPane.showMessageDialog(null,
    "CORRECT, you now have "+points+" points");
    }
    else
    {
    points = points-5;
    JOptionPane.showMessageDialog(null,
    "INCORRECT, you now have "+points+" points");
    }
    }

    static void blue()
    {
    first = (int)((Math.random()*10)+1);
    secon = (int)((Math.random()*10)+1);

    int oper = (Math.random()*3)+1;

    if(oper==1)
    {
    int ans = Integer.parseInt(JOptionPane.showInputDialog
    (first+" + "+second+" = ?"));
    if(ans==(first+secon))
    {
    points = points+5;
    JOptionPane.showMessageDialog(null,
    "CORRECT, you now have "+points+" points");
    }
    else
    {
    points = points-5;
    JOptionPane.showMessageDialog(null,
    "INCORRECT, you now have "+points+" points");
    }
    }
    else
    {
    if(oper==2)
    {
    ans = Integer.parseInt(JOptionPane.showInputDialog
    (first+" - "+second+" = ?"));

    if(ans==(first-secon))
    {
    points = points+5;
    JOptionPane.showMessageDialog(null,
    "CORRECT, you now have "+points+" points");
    }
    else
    {
    points = points-5;
    JOptionPane.showMessageDialog(null,
    "INCORRECT, you now have "+points+" points");
    }
    }
    else
    {
    if(oper==3)
    {
    ans = Integer.parseInt(JOptionPane.showInputDialog
    (first+" x "+second+" = ?"));
    if(ans==(first*secon))
    {
    points = points+5;
    JOptionPane.showMessageDialog(null,
    "CORRECT, you now have "+points+" points");
    }
    else
    {
    points = points-5;
    JOptionPane.showMessageDialog(null,
    "INCORRECT, you now have "+points+" points");
    }
    }
    }
    }
    }
    }







    now to the errors.. they are all symbol not found, therefore my thinking is that its one small error that i have repeated











    ERRORS

    ----jGRASP exec: javac -g RedBlue.java

    RedBlue.java:36: error: cannot find symbol
    int user = Integer.parseInt(JOptionpane.showInputDialog
    ^
    symbol: variable JOptionpane
    location: class RedBlue
    RedBlue.java:40: error: cannot find symbol
    points = points+20;
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:40: error: cannot find symbol
    points = points+20;
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:44: error: cannot find symbol
    points = points+20;
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:44: error: cannot find symbol
    points = points+20;
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:67: error: cannot find symbol
    first = (int)((Math.random()*10)+1);
    ^
    symbol: variable first
    location: class RedBlue
    RedBlue.java:68: error: cannot find symbol
    secon = (int)((Math.random()*10)+1);
    ^
    symbol: variable secon
    location: class RedBlue
    RedBlue.java:70: error: cannot find symbol
    ans = Integer.parseInt(JOptionPane.showInputDialog
    ^
    symbol: variable ans
    location: class RedBlue
    RedBlue.java:71: error: cannot find symbol
    (first+secon+", "+first+secon+secon+", "+first+
    ^
    symbol: variable first
    location: class RedBlue
    RedBlue.java:71: error: cannot find symbol
    (first+secon+", "+first+secon+secon+", "+first+
    ^
    symbol: variable secon
    location: class RedBlue
    RedBlue.java:71: error: cannot find symbol
    (first+secon+", "+first+secon+secon+", "+first+
    ^
    symbol: variable first
    location: class RedBlue
    RedBlue.java:71: error: cannot find symbol
    (first+secon+", "+first+secon+secon+", "+first+
    ^
    symbol: variable secon
    location: class RedBlue
    RedBlue.java:71: error: cannot find symbol
    (first+secon+", "+first+secon+secon+", "+first+
    ^
    symbol: variable secon
    location: class RedBlue
    RedBlue.java:71: error: cannot find symbol
    (first+secon+", "+first+secon+secon+", "+first+
    ^
    symbol: variable first
    location: class RedBlue
    RedBlue.java:72: error: cannot find symbol
    secon+secon+secon+"... what is the fourth term?"));
    ^
    symbol: variable secon
    location: class RedBlue
    RedBlue.java:72: error: cannot find symbol
    secon+secon+secon+"... what is the fourth term?"));
    ^
    symbol: variable secon
    location: class RedBlue
    RedBlue.java:72: error: cannot find symbol
    secon+secon+secon+"... what is the fourth term?"));
    ^
    symbol: variable secon
    location: class RedBlue
    RedBlue.java:74: error: cannot find symbol
    if(ans==(first+(secon*4)))
    ^
    symbol: variable ans
    location: class RedBlue
    RedBlue.java:74: error: cannot find symbol
    if(ans==(first+(secon*4)))
    ^
    symbol: variable first
    location: class RedBlue
    RedBlue.java:74: error: cannot find symbol
    if(ans==(first+(secon*4)))
    ^
    symbol: variable secon
    location: class RedBlue
    RedBlue.java:76: error: cannot find symbol
    points = points+5;
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:76: error: cannot find symbol
    points = points+5;
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:78: error: cannot find symbol
    "CORRECT, you now have "+points+" points");
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:82: error: cannot find symbol
    points = points-5;
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:82: error: cannot find symbol
    points = points-5;
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:84: error: cannot find symbol
    "INCORRECT, you now have "+points+" points");
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:90: error: cannot find symbol
    first = (int)((Math.random()*10)+1);
    ^
    symbol: variable first
    location: class RedBlue
    RedBlue.java:91: error: cannot find symbol
    secon = (int)((Math.random()*10)+1);
    ^
    symbol: variable secon
    location: class RedBlue
    RedBlue.java:93: error: possible loss of precision
    int oper = (Math.random()*3)+1;
    ^
    required: int
    found: double
    RedBlue.java:98: error: cannot find symbol
    (first+" + "+second+" = ?"));
    ^
    symbol: variable first
    location: class RedBlue
    RedBlue.java:98: error: cannot find symbol
    (first+" + "+second+" = ?"));
    ^
    symbol: variable second
    location: class RedBlue
    RedBlue.java:99: error: cannot find symbol
    if(ans==(first+secon))
    ^
    symbol: variable first
    location: class RedBlue
    RedBlue.java:99: error: cannot find symbol
    if(ans==(first+secon))
    ^
    symbol: variable secon
    location: class RedBlue
    RedBlue.java:101: error: cannot find symbol
    points = points+5;
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:101: error: cannot find symbol
    points = points+5;
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:103: error: cannot find symbol
    "CORRECT, you now have "+points+" points");
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:107: error: cannot find symbol
    points = points-5;
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:107: error: cannot find symbol
    points = points-5;
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:109: error: cannot find symbol
    "INCORRECT, you now have "+points+" points");
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:116: error: cannot find symbol
    ans = Integer.parseInt(JOptionPane.showInputDialog
    ^
    symbol: variable ans
    location: class RedBlue
    RedBlue.java:117: error: cannot find symbol
    (first+" - "+second+" = ?"));
    ^
    symbol: variable first
    location: class RedBlue
    RedBlue.java:117: error: cannot find symbol
    (first+" - "+second+" = ?"));
    ^
    symbol: variable second
    location: class RedBlue
    RedBlue.java:119: error: cannot find symbol
    if(ans==(first-secon))
    ^
    symbol: variable ans
    location: class RedBlue
    RedBlue.java:119: error: cannot find symbol
    if(ans==(first-secon))
    ^
    symbol: variable first
    location: class RedBlue
    RedBlue.java:119: error: cannot find symbol
    if(ans==(first-secon))
    ^
    symbol: variable secon
    location: class RedBlue
    RedBlue.java:121: error: cannot find symbol
    points = points+5;
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:121: error: cannot find symbol
    points = points+5;
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:123: error: cannot find symbol
    "CORRECT, you now have "+points+" points");
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:127: error: cannot find symbol
    points = points-5;
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:127: error: cannot find symbol
    points = points-5;
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:129: error: cannot find symbol
    "INCORRECT, you now have "+points+" points");
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:136: error: cannot find symbol
    ans = Integer.parseInt(JOptionPane.showInputDialog
    ^
    symbol: variable ans
    location: class RedBlue
    RedBlue.java:137: error: cannot find symbol
    (first+" x "+second+" = ?"));
    ^
    symbol: variable first
    location: class RedBlue
    RedBlue.java:137: error: cannot find symbol
    (first+" x "+second+" = ?"));
    ^
    symbol: variable second
    location: class RedBlue
    RedBlue.java:138: error: cannot find symbol
    if(ans==(first*secon))
    ^
    symbol: variable ans
    location: class RedBlue
    RedBlue.java:138: error: cannot find symbol
    if(ans==(first*secon))
    ^
    symbol: variable first
    location: class RedBlue
    RedBlue.java:138: error: cannot find symbol
    if(ans==(first*secon))
    ^
    symbol: variable secon
    location: class RedBlue
    RedBlue.java:140: error: cannot find symbol
    points = points+5;
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:140: error: cannot find symbol
    points = points+5;
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:142: error: cannot find symbol
    "CORRECT, you now have "+points+" points");
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:146: error: cannot find symbol
    points = points-5;
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:146: error: cannot find symbol
    points = points-5;
    ^
    symbol: variable points
    location: class RedBlue
    RedBlue.java:148: error: cannot find symbol
    "INCORRECT, you now have "+points+" points");
    ^
    symbol: variable points
    location: class RedBlue
    63 errors

    ----jGRASP wedge2: exit code for process is 1.
    ----jGRASP: operation complete.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Error symbol not found Please help

    When you have a ton of errors, then you know that the problem is more than that there's something wrong with your program, no, the problem here is that there's something wrong with *how* you're programming. If you are not using an IDE, you must compile your code frequently, in fact you should do this after every 1 to 2 lines of code that is added, and you should not add any new code until all compilation errors have been fixed. I suggest that you restart this project and first create a program skeleton -- nothing but the class name and perhaps an empty main method, make sure that it compiles and then add your code 1-2 lines at a time, compiling and repairing as you go. Also, take care to use correct spelling and capitalization (it's JOptionPane, not JOptionpane), take care to make sure that you don't use variables that are not visible where you're trying to use them, such as the points variable which is declared inside of the main method and is only visible inside of the main method.

    Best of luck.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: Error symbol not found Please help

    laurenceshan: Please go through BB Code List - Java Programming Forum and edit your post accordingly.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Symbol not found - object invisible outside of class
    By stesteve in forum New To Java
    Replies: 5
    Last Post: 02-15-2012, 09:57 PM
  2. Method Graphics.drawString() - Symbol not found
    By km0r3 in forum AWT / Swing
    Replies: 1
    Last Post: 08-27-2010, 02:55 PM
  3. Replies: 9
    Last Post: 10-18-2008, 08:26 PM
  4. Compile: symbol not found
    By zuan in forum New To Java
    Replies: 7
    Last Post: 06-24-2008, 05:17 AM
  5. symbol not found error
    By rmartyce in forum New To Java
    Replies: 1
    Last Post: 05-23-2008, 05:58 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •