【发布时间】:2013-11-25 11:29:07
【问题描述】:
我在 android 中的一个编程语句遇到问题,它一直给我标签 230 丢失的错误,但我不知道做错了什么。任何帮助将不胜感激。
这是下面的程序;
public static void calculateGPA()
{
totalHours = 0.0D;
totalValue = 0.0D;
int i = 0;
if (i >= 8)
{
Object[] arrayOfObject = new Object[1];
arrayOfObject[0] = Double.valueOf(totalValue / totalHours);
GPA = String.format("%.2f", arrayOfObject);
if (!GPA.equals("NaN"))
break label230;
GPA = "0.00";
}
while (true)
{
return;
int j = collegeGradeSpinner[i].getSelectedItemPosition();
int k = collegeHourSpinner[i].getSelectedItemPosition();
if ((j != 0) && (k != 0))
switch (j)
{
default:
case 1:
case 2:
case 3:
case 4:
case 5:
}
while (true)
{
i++;
break;
totalValue += k * 4;
totalHours += k;
continue;
totalValue += k * 3;
totalHours += k;
continue;
totalValue += k * 2;
totalHours += k;
continue;
totalValue += k * 1;
totalHours += k;
continue;
totalHours += k;
}
label230: gpaTextView.setText(GPA);
}
}
【问题讨论】:
-
您的标签存在于封闭块内。你不能“闯入”这个块:阅读这个stackoverflow.com/questions/8802287/…
-
此代码是否是通过工具生成的,因为您的代码中有很多地方可以改进。例如GPA 的计算可以简单地完成如下 GPA = String.toString(Math.round(totalValue/totalHours, 2));根据您的要求,这可以以更简单的方式完成