我的GPA计算器代码昨天工作正常,但现在它返回错误:
package problemset.leveltwo;
import java.util.*;
public class gpaCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double mathGPA = 0;
double historyGPA = 0;
double englishGPA = 0;
double scienceGPA = 0;
double langGPA = 0;
// A+
double a = 4.00;
// A-
double b = 3.70;
// B+
double c = 3.30;
// B
double d = 3.00;
// B-
double e = 2.70;
// C+
double f = 2.30;
// C
double g = 2.00;
// C-
double h = 1.70;
// D+
double i = 1.30;
// D
double j = 1.00;
// D-
double k = 0.70;
// F
double l = 0;
System.out.println("Enter Your Math Grade (percentage)");
int mathGrade = scanner.nextInt();
System.out.println("Enter Your History Grade (percentage)");
int historyGrade = scanner.nextInt();
System.out.println("Enter Your English Grade (percentage)");
int englishGrade = scanner.nextInt();
System.out.println("Enter Your Science Grade (percentage)");
int scienceGrade = scanner.nextInt();
System.out.println("Enter Your Language Grade (percentage)");
int langGrade = scanner.nextInt();
// MATH GRADE
// Math = A
if (mathGrade >= 96) {
System.out.println("Math GPA = " + a);
mathGPA = 4.00;
}
// Math = A-
if (mathGrade < 96) {
if (mathGrade >= 90) {
System.out.println("Math GPA = " + b);
mathGPA = 3.70;
}
}
// Math B+
if (mathGrade < 90) {
if (mathGrade >= 86) {
System.out.println("Math GPA = " + c);
mathGPA = 3.30;
}
}
// Math B
if (mathGrade < 86) {
if (mathGrade >= 84) {
System.out.println("Math GPA = " + d);
mathGPA = 3.00;
}
}
// Math B-
if (mathGrade < 84) {
if (mathGrade >= 80) {
System.out.println("Math GPA = " + e);
mathGPA = 2.70;
}
}
// Math C+
if (mathGrade < 80) {
if (mathGrade >= 76) {
System.out.println("Math GPA = " + f);
mathGPA = 2.30;
}
}
// Math C
if (mathGrade < 76) {
if (mathGrade >= 73) {
System.out.println("Math GPA = " + g);
mathGPA = 2.00;
}
}
// Math C-
if (mathGrade < 73) {
if (mathGrade >= 70) {
System.out.println("Math GPA = " + h);
mathGPA = 1.70;
}
}
// Math D+
if (mathGrade < 70) {
if (mathGrade >= 66) {
System.out.println("Math GPA = " + i);
mathGPA = 1.30;
}
}
// Math D
if (mathGrade < 66) {
if (mathGrade >= 63) {
System.out.println("Math GPA = " + j);
mathGPA = 1.00;
}
}
// Math D-
if (mathGrade < 63) {
if (mathGrade >= 50) {
System.out.println("Math GPA = " + k);
mathGPA = 0.70;
}
}
// Math F
if (mathGrade < 50) {
System.out.println("Math GPA = " + l);
mathGPA = 0.00;
}
// HISTORY GRADE
// History = A
if (historyGrade >= 96) {
System.out.println("History GPA = " + a);
historyGPA = 4.00;
}
// History = A-
if (historyGrade < 96) {
if (historyGrade >= 90) {
System.out.println("History GPA = " + b);
historyGPA = 3.70;
}
}
// History B+
if (historyGrade < 90) {
if (historyGrade >= 86) {
System.out.println("History GPA = " + c);
historyGPA = 3.30;
}
}
// History B
if (historyGrade < 86) {
if (historyGrade >= 84) {
System.out.println("History GPA = " + d);
historyGPA = 3.00;
}
}
// History B-
if (historyGrade < 84) {
if (historyGrade >= 80) {
System.out.println("History GPA = " + e);
historyGPA = 2.70;
}
}
// History C+
if (historyGrade < 80) {
if (historyGrade >= 76) {
System.out.println("History GPA = " + f);
historyGPA = 2.30;
}
}
// History C
if (historyGrade < 76) {
if (historyGrade >= 73) {
System.out.println("History GPA = " + g);
historyGPA = 2.00;
}
}
// History C-
if (historyGrade < 73) {
if (historyGrade >= 70) {
System.out.println("History GPA = " + h);
historyGPA = 1.70;
}
}
// History D+
if (historyGrade < 70) {
if (historyGrade >= 66) {
System.out.println("History GPA = " + i);
historyGPA = 1.30;
}
}
// History D
if (historyGrade < 66) {
if (historyGrade >= 63) {
System.out.println("History GPA = " + j);
historyGPA = 1.00;
}
}
// History D-
if (historyGrade < 63) {
if (historyGrade >= 50) {
System.out.println("History GPA = " + k);
historyGPA = 0.70;
}
}
// History F
if (historyGrade < 50) {
System.out.println("History GPA = " + l);
historyGPA = 0;
}
// ENGLISH GRADE
// English = A
if (englishGrade >= 96) {
System.out.println("English GPA = " + a);
englishGPA = 4.00;
}
// English = A-
if (englishGrade < 96) {
if (englishGrade >= 90) {
System.out.println("English GPA = " + b);
englishGPA = 3.70;
}
}
// English B+
if (englishGrade < 90) {
if (englishGrade >= 86) {
System.out.println("English GPA = " + c);
englishGPA = 3.30;
}
}
// English B
if (englishGrade < 86) {
if (englishGrade >= 84) {
System.out.println("English GPA = " + d);
englishGPA = 3.00;
}
}
// English B-
if (englishGrade < 84) {
if (englishGrade >= 80) {
System.out.println("English GPA = " + e);
englishGPA = 2.70;
}
}
// English C+
if (englishGrade < 80) {
if (englishGrade >= 76) {
System.out.println("English GPA = " + f);
englishGPA = 2.30;
}
}
// English C
if (englishGrade < 76) {
if (englishGrade >= 73) {
System.out.println("English GPA = " + g);
englishGPA = 2.00;
}
}
// English C-
if (englishGrade < 73) {
if (englishGrade >= 70) {
System.out.println("English GPA = " + h);
englishGPA = 1.70;
}
}
// English D+
if (englishGrade < 70) {
if (englishGrade >= 66) {
System.out.println("English GPA = " + i);
englishGPA = 1.30;
}
}
// English D
if (englishGrade < 66) {
if (englishGrade >= 63) {
System.out.println("English GPA = " + j);
englishGPA = 1.00;
}
}
// English D-
if (englishGrade < 63) {
if (englishGrade >= 50) {
System.out.println("English GPA = " + k);
englishGPA = 0.70;
}
}
// English F
if (englishGrade < 50) {
System.out.println("English GPA = " + l);
englishGPA = 0;
}
// SCIENCE GRADE
// Science = A
if (scienceGrade >= 96) {
System.out.println("Science GPA = " + a);
scienceGPA = 4.00;
}
// Science = A-
if (scienceGrade < 96) {
if (scienceGrade >= 90) {
System.out.println("Science GPA = " + b);
scienceGPA = 3.70;
}
}
// Science B+
if (scienceGrade < 90) {
if (scienceGrade >= 86) {
System.out.println("Science GPA = " + c);
scienceGPA = 3.30;
}
}
// Science B
if (scienceGrade < 86) {
if (scienceGrade >= 84) {
System.out.println("Science GPA = " + d);
scienceGPA = 3.00;
}
}
// Science B-
if (scienceGrade < 84) {
if (scienceGrade >= 80) {
System.out.println("Science GPA = " + e);
scienceGPA = 2.70;
}
}
// Science C+
if (scienceGrade < 80) {
if (scienceGrade >= 76) {
System.out.println("Science GPA = " + f);
scienceGPA = 2.30;
}
}
// Science C
if (scienceGrade < 76) {
if (scienceGrade >= 73) {
System.out.println("Science GPA = " + g);
scienceGPA = 2.00;
}
}
// Science C-
if (scienceGrade < 73) {
if (scienceGrade >= 70) {
System.out.println("Science GPA = " + h);
scienceGPA = 1.70;
}
}
// Science D+
if (scienceGrade < 70) {
if (scienceGrade >= 66) {
System.out.println("Science GPA = " + i);
scienceGPA = 1.30;
}
}
// Science D
if (scienceGrade < 66) {
if (scienceGrade >= 63) {
System.out.println("Science GPA = " + j);
scienceGPA = 1.00;
}
}
// Science D-
if (scienceGrade < 63) {
if (scienceGrade >= 50) {
System.out.println("Science GPA = " + k);
scienceGPA = 0.70;
}
}
// Science F
if (scienceGrade < 50) {
System.out.println("Science GPA = " + l);
scienceGPA = 0;
}
// LANGUAGE GRADE
// Lang = A
if (langGrade >= 96) {
System.out.println("Language GPA = " + a);
langGPA = 4.00;
}
// Lang = A-
if (langGrade < 96) {
if (langGrade >= 90) {
System.out.println("Language GPA = " + b);
langGPA = 3.70;
}
}
// lang B+
if (langGrade < 90) {
if (langGrade >= 86) {
System.out.println("Language GPA = " + c);
langGPA = 3.30;
}
}
// Lang B
if (langGrade < 86) {
if (langGrade >= 84) {
System.out.println("Language GPA = " + d);
langGPA = 3.00;
}
}
// Lang B-
if (langGrade < 84) {
if (langGrade >= 80) {
System.out.println("Language GPA = " + e);
langGPA = 2.70;
}
}
// Lang C+
if (langGrade < 80) {
if (langGrade >= 76) {
System.out.println("Language GPA = " + f);
langGPA = 2.30;
}
}
// Lang C
if (langGrade < 76) {
if (langGrade >= 73) {
System.out.println("Language GPA = " + g);
langGPA = 2.00;
}
}
// Lang C-
if (langGrade < 73) {
if (langGrade >= 70) {
System.out.println("Language GPA = " + h);
langGPA = 1.70;
}
}
// Lang D+
if (langGrade < 70) {
if (langGrade >= 66) {
System.out.println("Language GPA = " + i);
historyGPA = 1.30;
}
}
// Lang D
if (langGrade < 66) {
if (langGrade >= 63) {
System.out.println("Language GPA = " + j);
langGPA = 1.00;
}
}
// Lang D-
if (langGrade < 63) {
if (langGrade >= 50) {
System.out.println("Language GPA = " + k);
langGPA = 0.70;
}
}
// Lang F
if (langGrade < 50) {
System.out.println("Language GPA = " + l);
langGPA = 0;
}
//Credits taken = 12-17
System.out.println("Math Worth (credits):");
int mathWorth = scanner.nextInt();
System.out.println("History Worth (credits):");
int historyWorth = scanner.nextInt();
System.out.println("English Worth (credits):");
int englishWorth = scanner.nextInt();
System.out.println("Science Worth (credits):");
int scienceWorth = scanner.nextInt();
System.out.println("Language Worth (credits):");
int langWorth = scanner.nextInt();
double newMath = mathGPA * mathWorth;
double newHistory = historyGPA * historyWorth;
double newEnglish = englishGPA * englishWorth;
double newScience = scienceGPA * scienceWorth;
double newLang = langGPA * langWorth;
int creditsTaken = mathWorth + historyWorth + englishWorth + scienceWorth + langWorth;
double total = (newMath + newHistory + newEnglish + newScience + newLang) / creditsTaken;
System.out.println("Total GPA = " + total);
}
}
重新调整的错误是:
Exception in thread "main" java.lang.NoClassDefFoundError: problemset/leveltwo/gpaCalculator
Caused by: java.lang.ClassNotFoundException: problemset.leveltwo.gpaCalculator
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
如果有人能告诉我这些错误是什么意思以及如何修复它们我会非常感激。提前谢谢!