0
戻り値を持つメソッドのエラー
三角形の面積を出すファイルを作成して、コンパイルしたらなぜかTAクラスのcheck,calculateメソッドで
";"がありませんというエラーが出ます。
教科書としている本を読んでも、戻り値をもつメソッドの宣言文には;が書いてありません。
どういうエラーでしょうか?また、解決方法も教えてください。
class TA{
static double[][] p=new double[3][2];
static double[] l=new double[3];
static double S,max,max_n;
void SetPoint(double x1,double y1,double x2,double y2,double x3,double y3){
p[0][0]=x1;
p[0][1]=y1;
p[1][0]=x2;
p[1][1]=y2;
p[2][0]=x3;
p[2][1]=y3;
max=0;
l[0]=Math.sqrt(Math.pow(Math.abs(p[0][0]-p[1][0]),2)*Math.pow(Math.abs(p[0][1]-p[1][1]),2));
l[1]=Math.sqrt(Math.pow(Math.abs(p[1][0]-p[2][0]),2)*Math.pow(Math.abs(p[1][1]-p[2][1]),2));
l[2]=Math.sqrt(Math.pow(Math.abs(p[0][0]-p[2][0]),2)*Math.pow(Math.abs(p[0][1]-p[2][1]),2));
for(int i=0;i<l.length;i++){
if(l[i]>max){
max=l[i];
max_n=i;
}
}
boolean check(){
boolean ch;
double l1=0;
double l2=0;
for(int i=0;i<l.length;i++){
if(i != max_n){
l1 += l[i];
if(l2==0)
l2 =l[i];
else
l2 =Math.abs(l2-l[i]);
}
}
if(l1>=max || max<=l2)
ch=false;
else if(p[0][0]==p[1][0] && p[0][0]==p[2][0])
ch=false;
else if(p[0][1]==p[1][1] && p[0][1]==p[2][1])
ch=false;
else
ch=true;
return ch;
}
double calculate(){
int s;
for(int i=0;i<l.length;i++){
s += l[i]/2;
}
S = s;
for(int i=0;i<l.length;i++){
S *= s-l[i];
}
S=Math.sqrt(S);
return S;
}
}
class triangle{
public static void main(String[] args)throws IOException{
TA ta =new TA();
System.out.println("3点の座標をX座標、Y座標の順で登録してください。");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String[] str=new String[6];
double[] n=new double[str.length];
for(int i=0;i<str.length;i++){
str[i]=br.readLine();
n[i]=Double.parseDouble(str[i]);
}
ta.Setpoint(n[0],n[1],n[2],n[3],n[4],n[5]);
if(ta.check() == true)
System.out.println(ta.calculate());
else
System.out.println("三角形を生成できません。");
}
}