1 Reply Latest reply: Mar 7, 2013 10:09 PM by r035198x RSS

    method GPA calculator, need help using charAt()

    995596
      I am writing a method to calculate your gpa given the letter grade and I am having trouble getting the method to display the gpa.
      Here is the method as it stands:
      public static double GPA(char letterGrade)
           {
                double GPA=0;          //holds GPA     
                if(lettergrade.equals(""))
                {
                     GPA = 4.0;
                }
                else
                {
                     if(letterGrade.charAt(B))
                     {
                          GPA = 3.0;
                     }
                     else
                     {
                          if(letterGrade.equals("C"))
                          {
                               GPA = 2.0;
                          }
                          else
                          {
                               if(letterGrade.equals("D"))
                               {
                                    GPA = 1.0;
                               }
                               else
                               {
                                    if(letterGrade.equals("F"))
                                    {
                                         GPA = 0.0;
                                    }
                               }
                          }
                     }
                }
                return GPA;
           }//end GPA(char)

      Any help would be greatly appreciated!

      I am getting the error char cannot be dereferenced.