Reputation: 1
So, here's my code:
import java.util.Scanner;
public class FootballsGivenAway
{
public static void main(String [] args)
{
int FinalScore;
**int TouchdownNumber=BallsGivenAway;**
int BallsGivenAway=TouchdownNumber;
Scanner inputDevice= new Scanner(System.in);
System.out.print("What was the final score of the Carolina Panthers? ");
FinalScore=inputDevice.nextInt();
System.out.print("Out of the points the Panthers scored, how many of them were touchdowns? ");
TouchdownNumber=inputDevice.nextInt();
System.out.println("The Carolina Panthers gave away this number of footballs today: " + BallsGivenAway);
}
}
The compiler keeps returning the "Cannot find symbol" error on the line in bold. What must I do to correct this issue?
Upvotes: 0
Views: 41
Reputation: 5637
You can't use a local variable in Java before you've declared it. If you look at your code, you can see that you're trying to set TouchdownNumber
to BallsGivenAway
before you've declared BallsGivenAway
on the next line.
Also:
BallsGivenAway
back to TouchDownNumber
? You're defining two variables whose value is supposed to be ... the other one?Upvotes: 1