[英]error illegal start of expression
I keep getting: 我不断得到:
illegal start of expression,';" expected System.exit(0), and reached end of file while parsing
表达式的非法开头,';“预期为System.exit(0),并且在解析时已到达文件末尾
This is the description of what its suppose to do and the code. 这是它应该执行的操作和代码的描述。
Problem to Solve: 要解决的问题:
How much should I study outside of class? 我应该在课外学习多少?
Issue: 问题:
Your fellow students need help. 您的同学需要帮助。 This is their first year in college and they need to determine how many hours they need to study to get good grades.
这是他们上大学的第一年,他们需要确定需要学习多少小时才能获得良好的成绩。
Study Hrs Per Week Per Credit Grade
5: A,
4: B,
3: C,
2: D,
0: F,
Project Specifications: 项目规格:
Below is my code: 下面是我的代码:
import javax.swing.JOptionPane; //Needed for the dialogue box
/**
This program shows the student the grade they will receive
or how much to study for a certain grade.
*/
public class MoultonAlainaProject1
{
public static void main(String[] args)
{
string wantedGrade, desiredGrade, name, input;
char finalGrade;
int gradeA = 5;
int gradeB = 4;
int gradeC = 3;
int gradeD = 2;
int gradeF = 0;
float studyHrs;
int creditHrs, userChoice;
//Scanner for keyboard input
Scanner keyboard = new Scanner(System.in);
name = JOptionPane.showInputDialog("Please enter your name.");
input = JOptionPane.showInputDialog("How many credit hours do you plan on taking this semester?");
creditHrs = integer.parseInt(input);
input = JOption.showInputDialog("If you would like to know the amount of hours you should study for the amount of" +
"credit hours press 1. If you would like to know the grade you would receive by" +
"entering the amount of hours you plan to study press 2.");
userChoice = integer.parseInt(input);
if (userChoice == 1)
{
desiredGrade = JOptionPane.showInputDialog("Enter the grade you would like to receive.");
if (desiredGrade == 'A' || 'a')
{
wantedGrade = gradeA;
}
else
{
if (desiredGrade == 'B' ||'b')
{
wantedGrade = gradeB;
}
else
{
if (desiredGrade == 'C' || 'c')
{
wantedGrade = gradeC;
}
else
{
if (desiredGrade == 'D' || 'd')
{
wantedGrade = gradeD;
}
else
{
if (desiredGrade == 'F' || 'f')
{
wantedGrade = gradeF;
}
else
{
System.out.printIn("Error: you have not entered a valid input.");
}
}
}
}
}
studyHrs = wantedGrade * creditHrs;
}
else
{
if (userChoice == 2)
{
input = JOptionPane.showInputDialog("Enter the amount of hours you plan to study a week.");
studyHrs = integer.parseInt(input);
wantedGrade = studyHrs/creditHrs;
if (wantedGrade >= 5)
{
finalGrade = "A";
}
else
{
if (wantedGrade >= 4)
{
finalGrade = "B";
}
else
{
if (wantedGrade >= 3)
{
finalGrade = "C";
}
else
{
if (wantedGrade >= 2)
{
finalGrade = "D";
}
else
{
if (wantedGrade < 2)
{
finalGrade = "F";
}
}
}
}
}
JOptionPane.showMessageDialog(null, name+ ", you are taking " +creditHrs+ "credit hours, you should study " +studyHrs+ " hours a week to receive " +finalGrade+ " in your classes."
System.exit(0);
}
}
I have checked the braces a ton of times but I probably missed something somewhere 我已经检查了很多次牙套,但是我可能错过了某处的东西
You have about 20 compile time errors. 您大约有20个编译时错误。
I see missing imports, string written with lowercase, unclosed brackets, 我看到丢失的导入,用小写字母写的字符串,未闭合的括号,
unclosed curly braces, assigning string values to char variables, etc. 未封闭的花括号,将字符串值分配给char变量等。
See below and fix them. 请参阅下文并修复它们。
Description Resource Path Location Type
Type mismatch: cannot convert from String to char MoultonAlainaProject1.java /TEST/src line 107 Java Problem
Type mismatch: cannot convert from String to char MoultonAlainaProject1.java /TEST/src line 101 Java Problem
Type mismatch: cannot convert from String to char MoultonAlainaProject1.java /TEST/src line 95 Java Problem
Type mismatch: cannot convert from String to char MoultonAlainaProject1.java /TEST/src line 89 Java Problem
integer cannot be resolved MoultonAlainaProject1.java /TEST/src line 83 Java Problem
The method printIn(String) is undefined for the type PrintStream MoultonAlainaProject1.java /TEST/src line 69 Java Problem
integer cannot be resolved MoultonAlainaProject1.java /TEST/src line 33 Java Problem
JOption cannot be resolved MoultonAlainaProject1.java /TEST/src line 30 Java Problem
Syntax error, insert "}" to complete MethodBody MoultonAlainaProject1.java /TEST/src line 124 Java Problem
Syntax error on token(s), misplaced construct(s) MoultonAlainaProject1.java /TEST/src line 122 Java Problem
exit cannot be resolved or is not a field MoultonAlainaProject1.java /TEST/src line 122 Java Problem
Syntax error on token(s), misplaced construct(s) MoultonAlainaProject1.java /TEST/src line 120 Java Problem
Type mismatch: cannot convert from String to char MoultonAlainaProject1.java /TEST/src line 113 Java Problem
Syntax error, insert "}" to complete ClassBody MoultonAlainaProject1.java /TEST/src line 9 Java Problem
Scanner cannot be resolved to a type MoultonAlainaProject1.java /TEST/src line 23 Java Problem
string cannot be resolved to a type MoultonAlainaProject1.java /TEST/src line 12 Java Problem
integer cannot be resolved MoultonAlainaProject1.java /TEST/src line 28 Java Problem
Scanner cannot be resolved to a type MoultonAlainaProject1.java /TEST/src line 23 Java Problem
JOptionPane.showMessageDialog(null, name+ ", you are taking " +creditHrs+ "credit hours, you should study " +studyHrs+ " hours a week to receive " +finalGrade+ " in your classes."
The showMessageDialog()-method is not complete. showMessageDialog()方法不完整。 You are missing a closing bracket and semicolon.
您缺少右括号和分号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.