title: Java Grade Calculator 2
body: <p>This is my code:</p>
  
  <pre><code>package gradecalculator;
  
  import java.util.Scanner;
  
  public class GradeCalculator 
  {
      public static void main(String[] args) 
      {
          String categoryName = null;
          double categoryGrade;
          double categoryWorth;
          double Grade = 0;
  
          String[] nameArray = new String[10];
          double[] gradeArray = new double[10];
          double[] worthArray = new double[10];
          double[] categoryArray = new double[10];
  
          int c = 0;
          int c1 = 0;
  
          Scanner entry = new Scanner(System.in);
  
          while(!(categoryName = entry.next()).equals("Quit"))
          {            
              categoryGrade = entry.nextDouble();
              gradeArray[c] = categoryGrade;
  
              categoryWorth = entry.nextDouble();
              worthArray[c] = categoryWorth;
  
              categoryName = entry.nextLine();
              nameArray[c] = categoryName;
  
              categoryArray[c] = finalCategory(categoryGrade, categoryWorth);
  
              c++;
          }
  
          while(c != 0)
          {
              System.out.printf("%S:\t%f%%\tWorth: %f\n", nameArray[c1], gradeArray[c1], worthArray[c1]);
              c--;
              c1++;
          }
  
          while(c1 != 0)
          {
              Grade = Grade + categoryArray[c];
              c1--;
              c++;
          }
      }
  
      public static double finalCategory(double Grade, double Worth)
      {
          return (Grade * (Worth / 100));
      }
  }
  </code></pre>
  
  <p>The error occurs as soon as I enter the 3rd input (categoryName) - it appears is at line 29:</p>
  
  <pre><code>categoryWorth = entry.nextDouble();
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Exception in thread "main" java.util.InputMismatchException
      at java.util.Scanner.throwFor(Scanner.java:864)
      at java.util.Scanner.next(Scanner.java:1485)
      at java.util.Scanner.nextDouble(Scanner.java:2413)
      at gradecalculator.GradeCalculator.main(GradeCalculator.java:26)
  Java Result: 1
  </code></pre>
  
  <p>I am not sure what is causing the error, considering the line that Netbeans is giving me has nothing to do with the string input. If anyone knows how I can fix this, I would greatly appreciate it. Thanks.</p>