Results 1 to 3 of 3
- 09-24-2012, 06:49 PM #1
Member
- Join Date
- Sep 2012
- Posts
- 1
- Rep Power
- 0
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.
-
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.
- 09-25-2012, 04:27 AM #3
Re: Error symbol not found Please help
laurenceshan: Please go through BB Code List - Java Programming Forum and edit your post accordingly.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Symbol not found - object invisible outside of class
By stesteve in forum New To JavaReplies: 5Last Post: 02-15-2012, 09:57 PM -
Method Graphics.drawString() - Symbol not found
By km0r3 in forum AWT / SwingReplies: 1Last Post: 08-27-2010, 02:55 PM -
cannot find symbol symbol :constructor Error. Please help! =(
By KalEl in forum New To JavaReplies: 9Last Post: 10-18-2008, 08:26 PM -
Compile: symbol not found
By zuan in forum New To JavaReplies: 7Last Post: 06-24-2008, 05:17 AM -
symbol not found error
By rmartyce in forum New To JavaReplies: 1Last Post: 05-23-2008, 05:58 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks