2014-09-14 4 views
0

헤론의 공식을 사용하여 삼각형의 면적을 계산하려하지만, 추가 할 때 print 문이 더 이상 작동하지 않고 프로그램이 컴파일되지 않기 때문에 Math.pow 함수에서 뭔가 잘못하고 있다고 생각합니다.Java 지수법의 구문이 잘못 되었습니까?

Challenge.java:22: error: '.class' expected 
     area= Math.pow(double s,double b=.5) // this line has the error 
          ^
Challenge.java:22: error: ';' expected 
     area= Math.pow(double s,double b=.5) // this line has the error 
          ^
Challenge.java:22: error: ';' expected 
     area= Math.pow(double s,double b=.5) // this line has the error 
             ^
3 errors 

이러한 오류가 무엇을 의미합니까 :

public class Challenge 
{ 
    public static void main(String[] args) 
    { 
     double a; 

     a = triangleArea(3, 3, 3); 
     System.out.println("A triangle with sides 3,3,3 has an area of:" + a); 

     a = triangleArea(3, 4, 5); 
     System.out.println("A triangle with sides 3,4,5 has an area of:" + a); 

     a = triangleArea(9, 9, 9); 
     System.out.println("A triangle with sides 9,9,9 has an area of:" + a); 
    } 

    public static double triangleArea(int a, int b, int c) 
    { 
     double area; 
     double s = (a+b+c)/2; 
     s= (s*(s-a)*(s-b)*(s-c)); 
     area= Math.pow(double s,double b=.5) // this line has the error 
     return area; 
    } 
} 

컴파일러는 다음과 같은 오류가 나열이 내가 가진 무엇인가? 어떻게 수정합니까?

area= Math.pow(double s,double b=.5)  

같은 것을해야한다

+0

** 당신은 어떻게해야합니까 어떤 오류? **가 – SLaks

+2

'지역 = Math.pow (더블의 두 번 b = .5)'... WTF? 당신은'area = Math.pow (s, b);를 의미합니까? 그리고 그게'.5'의 의미입니까? – Tom

+1

구문을 고안하지 마십시오. Java를 사용하십시오. – EJP

답변

1

이,

area = Math.pow(s,0.5); 
return area; 
+0

고맙다. 지금 편집하고있다. – Acehilm

관련 문제