类预期错误。需要简单的程序

问题描述:

帮助当我运行这个程序,我得到这些错误:类预期错误。需要简单的程序

Testscore.java:26: class expected 
      grade = double.parseDouble(strInput); 
         ^
Testscore.java:26: ';' expected 
      grade = double.parseDouble(strInput); 
            ^
Testscore.java:26: not a statement 
      grade = double.parseDouble(strInput); 
            ^
Testscore.java:26: ';' expected 
      grade = double.parseDouble(strInput); 
              ^
4 errors 

我有double.parseDouble(strInput);正确的?

import javax.swing.*; 
import java.lang.IllegalArgumentException; 

public class Testscore 
{ 
    public static void main(String[] args) 
    { 
     int numberofTests = 0; 

     double grade = new double[numberofTests]; 

     double startgrade = 0; 

     String strInput; 

    // Get how many tests are used 

     strInput = JOptionPane.showInputDialog(null, "How many tests do you have? "); 
     numberofTests = Integer.parseInt(strInput); 

     grade = new double[(int) numberofTests]; 

     for (int index = 0; index < grade.length; index++) 
     { 
      strInput = JOptionPane.showInputDialog(null, "Enter Test Score." + (index + 1)); 
      grade = double.parseDouble(strInput); 

      if (grade[index] < 0|| grade[index] > 100) 
      { 
       try 
       { 
        throw new InvalidTestScore(); 
       } 

       catch (InvalidTestScore e) 
       { 
        e.printlnStackTrace(); 
       } 
      } 
     } 

     for (int index = 0; index < grade.length; index++) 

      { 
       startgrade += grade[index]; 
      } 

      average = startgrade/grade.length; 

      System.out.print("The average is: " + average); 

    } 
} 

这是Double,资本D

注意doubleDouble之间的区别。 “小”双是原始类型。另一个是班级 - java.lang.Double。你可以在类上调用类似parseDouble(..)的方法,而不是原始类型。 “big”double也被称为“包装类”,因为它将原始类型包装到一个类中。