救命啊,问题出在哪?

yorkzjy yorkzjy 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
写了一个java的程序,读取文件的数字,可是不知道哪里有个exception了,请高手指点:
这是data.txt

1.25 0
-1.25 2
0.0 0
-1.25 0
1.0 2
0.0 0
3.33 -1
-1.375 1
1.0 2
1.0 1
0.0 0
-4.75 2
-3.0 -2
3.0 2
0.0 0



import java.util.*;
import java.io.*;

public class test
{

public static void main(String[] args) //throws Exception
{

try{
double tmpCoef;
int tmpExpo;
BufferedReader br = new BufferedReader(new FileReader(new File("data.txt")));
String sLine = "";
int flag = 0;


while ((sLine = br.readLine()) != null)
{
//System.out.println(flag);
String[] ss = sLine.split(" ");
tmpCoef = Double.parseDouble(ss[0]);
tmpExpo = Integer.parseInt(ss[1]);// reads from the file
//System.out.println(tmpCoef+" "+tmpExpo);

//double absTmpCoef = absValue(tmpCoef);
//now stores it to the polynominal
if ( tmpExpo != 0 ||tmpCoef !=0.0 )
{
if (flag == 1)
{
//store the data into a
System.out.println("a: "+flag);
//a.display();
}
else if (flag == 2)
{

//store the data into b
//b.addTerm(tmpCoef, tmpExpo);
System.out.println("b: "+ flag);

}
else if (flag == 3)
{
//store the data into c
//c.addTerm(tmpCoef, tmpExpo);
System.out.println("c: "+ flag);
}
else if (flag ==4)
{
//store the data into d
//d.addTerm(tmpCoef,tmpExpo);
System.out.println("d: "+ flag);
}
else
{
break;
}
}


if (tmpCoef == 0.00 && tmpExpo == 0)
{
flag++;
//continue;
}

}


}

catch(Exception e)
{
System.out.println("exception caught");

}


}
}
...全文
评论 10
收藏 已收藏
分享
返回顶部
yorkzjy
Java SE 62,620 成员 307,251 内容