Java charAt method

Error states
init:
deps-jar:
Compiling 1 source file to C:\Documents and Settings\Angela\My Documents\NetBeansProjects\CharAtMethod\build\classes
C:\Documents and Settings\Angela\My Documents\NetBeansProjects\CharAtMethod\src\charatmethod\Grade.java:28: illegal start of expression
    private String letterGrade;
C:\Documents and Settings\Angela\My Documents\NetBeansProjects\CharAtMethod\src\charatmethod\Grade.java:29: reached end of file while parsing
}
Any help would greatly be appreciated.

*****************************************
package charatmethod;
import java.util.Scanner;

public class CharAtMethod
{

public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
 
System.out.println("Enter a letter grade:");
String input = in.nextLine();

Grade g = new Grade(input);

double grade = g.getNumericGrade();
System.out.println("Numeric value: " + grade);
}

}
*************************************
package charatmethod;
public class Grade
{
    public Grade(String initGrade)
    {
        letterGrade = initGrade;
    }
public double getNumericGrade()
{
    double grade = 0;
switch(letterGrade.charAt(0))
{
case 'A': grade = 4.0;break;
case 'B': grade = 3.0; break;
case 'C': grade = 2.0; break;
case 'D': grade = 1.0; break;
default: grade = 0.0; break;

}

for (int i = 0; i < letterGrade.length(); i++)
{
   if (letterGrade.charAt(i) == '-')  
       grade = grade - 0.3;
     else if (letterGrade.charAt(i) == '+')
        grade = grade + 0.3;
}  
    private String letterGrade
}
ca1358Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MicheleMarconCommented:
private String letterGrade
^^^^^^^^^^^^^^^^^

 private String letterGrade;

You forgot the ";"
0
ca1358Author Commented:
still getting
init:
deps-jar:
Compiling 1 source file to C:\Documents and Settings\Angela\My Documents\NetBeansProjects\CharAtMethod\build\classes
C:\Documents and Settings\Angela\My Documents\NetBeansProjects\CharAtMethod\src\charatmethod\Grade.java:28: illegal start of expression
    private String letterGrade;
C:\Documents and Settings\Angela\My Documents\NetBeansProjects\CharAtMethod\src\charatmethod\Grade.java:29: reached end of file while parsing
}
0
CEHJCommented:
Post current code *in the code snippet window* please
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

pellepCommented:
You're missing a curly bracket ( "}" ) before the offending variable declaration to close the getNumericGrade() function.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MicheleMarconCommented:
I suggest to use a systax-checking IDE, such as netbeans www.netbeans.org
0
ca1358Author Commented:
Solution mssing return statment
Thank for the input.


****************************************************8
package charatmethod;
import java.util.Scanner;
 
public class CharAtMethod
{
 
public static void main(String[] args) 
{
Scanner in = new Scanner(System.in);
 
System.out.println("Enter a letter grade:");
String input = in.nextLine();
 
Grade g = new Grade(input);
 
double grade = g.getNumericGrade();
 
System.out.println("Numeric value: " + grade);
}
}
*****************************************
package charatmethod;
public class Grade
{
    public Grade(String initGrade)
    {
        letterGrade = initGrade;
    }
public double getNumericGrade()
{
    double grade = 0;
switch(letterGrade.charAt(0)) 
{
case 'A': grade = 4.0;break;
case 'B': grade = 3.0; break;
case 'C': grade = 2.0; break;
case 'D': grade = 1.0; break;
default: grade = 0.0; break;
 
}
 
for (int i = 0; i < letterGrade.length(); i++)
{
   if (letterGrade.charAt(i) == '-')   
       grade = grade - 0.3;
     else if (letterGrade.charAt(i) == '+')
        grade = grade + 0.3;
}
    return grade;
            
}  
    private String letterGrade;
}

Open in new window

0
ca1358Author Commented:
Thanks for the input!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.