ExamNotes.net
Welcome, Guest. Please login or register.
October 24, 2014, 06:17:05 AM

Login with username, password and session length
* Home Help Search Login Register
+  ExamNotes.net
|-+  General discussions
| |-+  Programming Forum
| | |-+  I need help with my logic.
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: I need help with my logic.  (Read 1903 times)
Chanss_R
Member
Jr. Member
**
Offline Offline

Posts: 69

0


View Profile WWW
« on: October 08, 2006, 03:54:09 PM »

I am trying to get this program to return the total number of grades entered as well as the total number of A's, B's C'a etc.
I am new at this and just needs some guidance.




Error:

Exception in thread "main" java.lang.Error: Unresolved compilation problems:
   Char cannot be resolved to a type
   numberOfA cannot be resolved
   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);
               
               {
                   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();
                 
               }
                      sum = sum + next;
                       numberOfA++;
                      numberOfB++;
                      numberOfC++;
                      numberOfD++;
                      numberOfF++;
                      next = keyboard.nextInt();
                   
                                                   
               if (score >= 90)
                   grade = 'A';
               else if (score >= 80)
                   grade = 'B';
               else if (score >= 70)
                   grade  = 'C';
               else if (score >= 60)
                   grade = 'D';
               else
                  grade = 'F';
Logged

For all sad words of tongue and pen, The saddest are these,'It might have been'
ashyour
Junior Member

Offline Offline

Posts: 1

0


View Profile
« Reply #1 on: October 16, 2006, 01:39:41 PM »

{  //remove
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();

}//remove




Remove the curly braces which are indicated above and your problem will be solved.
these curly braces are making your veriables local so they are not accessible out side the curly braces.
for further support visit
http://www.braindumpindia.com
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2011, Simple Machines LLC Valid XHTML 1.0! Valid CSS!