我对编码很新,我一直在学习创建简单的程序。
我正在尝试创建一个名为roundGrade的程序,通过调用命令行将等级舍入到一个小数位。
错误说明:
Error: variable roundGrade might not have been initialized
这是我到目前为止编写的代码:
public static String roundGrade(double grade){
String roundGrade;
double R = Double.parseDouble(roundGrade);
R = Math.round(grade*10)/10;
roundGrade = Double.toString(R);
return roundGrade;
}
答案 0 :(得分:1)
您尝试在将roundGrade
设置为任何内容之前解析double R = Double.parseDouble(roundGrade);
R = Math.round(grade*10)/10;
(并且没有明显的目的)。此
double R = Math.round(grade*10)/10;
应该是
return String.format("%.1f", grade);
你的整个方法可能是
IF @NumberOfRuns = 1
SELECT * FROM Dataset1
IF @NumberOfRuns = 2
SELECT * FROM Dataset1
UNION ALL
SELECT * FROM Dataset2
IF @NumberOfRuns = 3
SELECT * FROM Dataset1
UNION ALL
SELECT * FROM Dataset2
UNION ALL
SELECT * FROM Dataset3