Re: Need help with my logic
- From: Lew <lew@xxxxxxxxxxx>
- Date: Sun, 08 Oct 2006 19:23:25 -0400
TechGurl wrote:
Error that I am getting:
Exception in thread "main" java.lang.Error: Unresolved compilation
problems:
numberOfA cannot be resolved //how I am to resolve this and the
others
numberOfB cannot be resolved
numberOfC cannot be resolved
numberOfD cannot be resolved
numberOfF cannot be resolved
at ExamScorer.main(ExamScorer.java:22)
public class ExamScorer
{
public static void main(String[] args)
{
System.out.println("Enter exam score: ");
int score;
char grade;
int sum;
int next;
String answer;
int countGrade = 0;
int countScore = 0;
Scanner keyboard = new Scanner(System.in);
{
These inner braces limit the scope of the variables declared within them.
System.out.println();
System.out.println("Enter all of the exam scores.");
sum=0;
int NumberOfA = 0;
int NumberOfB = 0;
int NumberOfC = 0;
int NumberOfD = 0;
int NumberOfF = 0;
next = keyboard.nextInt();
score = keyboard.nextInt();
grade = keyboard.next();
}
So outside them, the variables cannot be resolved.
sum = sum + next;
numberOfA++;
numberOfB++;
numberOfC++;
numberOfD++;
numberOfF++;
Remove the inner braces.
- Lew
.
- Follow-Ups:
- Re: Need help with my logic
- From: Simon Brooke
- Re: Need help with my logic
- From: TechGurl
- Re: Need help with my logic
- From: marcus.vinicius.lima
- Re: Need help with my logic
- References:
- Need help with my logic
- From: TechGurl
- Need help with my logic
- Prev by Date: Need help with my logic
- Next by Date: MouseAdapter Bug ??????
- Previous by thread: Need help with my logic
- Next by thread: Re: Need help with my logic
- Index(es):
Relevant Pages
|