嘿,我无法弄清楚如何将类型返回为字符串,因为我已将 outputGrade 定义为字符串,但我正在尝试计算单个数字。例如-mark=79 然后 outputGrade 字符串 = "9"
private static String printResult (int numAssignments, double studentMark)
{
int outputGradeSingle;
String outputGrade;
switch (numAssignments)
{
case 0: outputGrade="DNA-";
break;
case 1: case 2: case 3: case 4: outputGrade="DNC-";
break;
case 5: if (studentMark<50.0)
{
outputGrade="F-";
}
else
{
outputGradeSingle=(studentMark/10);
outputGrade= String.valueOf(outputGradeSingle);
}
break;
default: outputGrade="Not a valid amount of assignments, range is between 0 and 5";
break;
}
return outputGrade;
}
}