2013-02-26 1 views
0

이 코드 부분에 오류 메시지가 계속 표시됩니다. 나는 그것을 선언하고 그것을 다른 방식의 어조로 전달하려고 노력했다. 코드가 그다지 진전이 아니라면 사과드립니다. 나는 아직 초보자입니다.메서드 및 이중 전달

/* 
* To change this template, choose Tools | Templates 
* and open the template in the editor. 
*/ 

package javaapplication5; 
import java.util.Scanner; 

/** 
* 
* @author period3 
*/ 
public class JavaApplication5 { 

/** 
* @param args the command line arguments 
*/ 


public static void main(String[] args) { 


    double theresult; 
    theresult = area(double radius); 

Scanner reader; 
reader = new Scanner (System.in); 
System.out.println("Please enter the coordinates of a circle:"); 
newLine(); 
System.out.println("Outside point:"); 
newLine(); 
System.out.println("x1:"); 
int x1 = reader.nextInt(); 
newLine(); 
System.out.println("y1:"); 
int y1 = reader.nextInt(); 
newLine(); 
System.out.println("Center Point:"); 
newLine(); 
System.out.println("x2:"); 
int x2 = reader.nextInt(); 
newLine(); 
System.out.println("y2:"); 
int y2 = reader.nextInt(); 

System.out.println("The area of the circle is" + theresult); 

} 
public static double distance(int x1, int y1, int x2, int y2) 
{ 
double dx = x2 - x1; 
double dy = y2 - y1; 
double dsquared = dx*dx + dy*dy; 
double result = Math.sqrt (dsquared); 
return result; 
} 

public static double area(int x1, int y1, int x2, int y2) { 
double radius = distance (x1, y1, x2, y2); 
return radius; 
} 

public static double area(double radius) 
{ 
    double areaCircle; 
    areaCircle = (3.14 * (radius * radius)); 
    return areaCircle; 
} 


//NewLine Method 
public static void newLine() { 
System.out.println (""); 
} 
} 

라인 (24) (theresult = 지역 (더블 반경) 내 오류 메시지 :

double radius = distance(x1, y1, x2, y2); 

: 당신은 영역 방법을 사용하기 전에 먼저 반경을 계산해야

unexpected type 
    required: value 
    found: class 

'.class' expected 

';' expected 
---- 

답변

0

그런 다음 결과를 설정해야합니다.

theResult = area(radius); 

사용자 입력 후 (사용자가 x1, y1, x2y2, , 전에 theResult으로 인쇄 한 값)을 입력해야합니다.

distancearea 방법으로 전화를 걸고 있습니다. 매개 변수에 로컬 변수를 입력하기 만하면됩니다.

theResult = area(double radius); <- This is incorrect syntax. 
+0

정말 고마워요! 많은 도움이됩니다. 방법을 변경해야합니까? 또는 적절한 구문으로 theResult를 추가하십시오. – user2105795

+0

@ user2105795 아니요. – NominSim