我试图读取infile中的每个整数并将其传递给方法adScore,该方法确定字母等级,以及所有等级和最高考试分数和最低考试分数。但是我的while循环在执行for循环时并没有从infile中提取数据,因为我在执行system.out.print的for循环之后调试它。什么回报只是数字0-29这是我的循环计数器。可以帮助我了解我做错了什么,以便我可以从infile中提取成绩分数?需要从infile中取出每个整数并将其传递给方法
问候。
while(infile.hasNextInt())
{
for(int i=0; i <30; i++)//<-- it keeps looping and not pulling the integers from the file.
{
System.out.println(""+i);//<--- I placed this here to test what it is pulling in and it is just counting
//the numbers 0-29 and printing them out. How do I get each data from the infile to store
exam.adScore(i);//determines the count of A, B, C, D, F grades, total count, min and max
}
}
谢谢!我一直在努力研究如何从循环中的infile中获取数据。我不知道我是否可以使用另一个局部变量并将输出分配给该局部变量。这就说得通了!我永远不会忘记这一点,因为我已经在这一连串3天的时间里撞到了我的头:( – SaintClaire33 2012-04-15 12:32:42