0
に関するヘルプ、私はこのプログラムを実行すると、私はこれらのエラーを取得:クラスの予想されるエラー。簡単なプログラム
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);
}
}