왕초보인데요,제발도와주세요.프로그램오류 좀 봐 주세요.


[ 다음 글들 ] [ 이어서 글올리기(답하기) ] [ 자바 묻고 답하기 ]

글쓴이 :급해요.제발답변주세요. 2000년 5월 17일 01:01:49

진짜 왕초보라서 아직 개념도 안 잡혀
제 맘대로 막 짰는데요.제발 작은 충고라도...

<프로그램;삼각형을 나타내는 Triangle 클래스를 작성한다.특정 성질를 나타내는 부울 값을 반환하는 다음 메쏘드
를 포함해야 한다.
a. is_right (직각 삼각형)
b. is_scalene (두 변의 길이가 모두 다르다.)
c. is_isosceles (정확히 두 변의 길이가 같다.)
d. is_equilateral (세변의 길이가 모두 같다.)>


class Triangle {

Triangle_control tri1 = new Triange_control();

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

BufferedReader stdin = new BufferedReader
(new InputStreamReader (System.in));
int line1, line2, line3;


//세 변을 입력받는다.
System.out.println ("삼각형의 세 변을 입력하시오.");
System.out.println ("line1 :");
line1 = Integer.parseInt(stdin.readLine());
System.out.println ("line2 :");
line2 = Integer.parseInt(stdin.readLine());
System.out.println ("line3 :");
line3 = Integer.parseInt(stdin.readLine());

//삼각형의 타입을 결정한다.
if (tri1.is_right())
System.out.println ("직각 삼각형입니다.");
if (tri1.is_scalene())
System.out.println ("두변의 길이가 모두 다르다.");
if (tri1.is_isosceles())
System.out.println ("정확히 두 변의 길이가 같다.");
if (tri1.is_equilateral())
system.out.println ("세 변의 길이가 모두 같다.");
}//클래스 Triangle

//삼각형의 타입 조건을 설정해준다.
class Triangle_control {

public boolean is_right(){
boolean success = false;
if (
success = true; <-짜다 만 부분입니다.
else
return success;
}//직각 삼각형

public boolean is_scanlene() {
boolean success = false;
if ((line1 != line2) && (line2 != line3) && (line1 != line3))
success = true;
else
return success;
}//두 변의 길이가 모두 다르다

public boolean is_isosceles(){
boolean success = false;
if ((line1 == line2) || (line2 == line3) || (line1 == line3))
success =true;
else
return success;
}//정확히 두 변의 길이가 같다.

public boolean is_equilateral(){
boolean success = false;
if ((line1 == line2 ) && (line2 == line3) && (line1 == line3))
success = true;
else
return success;
}//세 변의 길이가 모두 같다.
}// 클래스Triangle_control


정말 막 짰죠?
1.BufferedReader가 뭔지?이렇게 써도 되나요?
2.Triangle_control를 이렇게 만들면 class Triange하고
연관이 안돼요.
3.직각삼각형성질 c*c = b*b + a*a 에서 c에 가장 긴
변을 주어야 하는 데 어떻게 해야 줄 수있을까요?

제발 답변 주세요.





다음 글들:



이어서 글올리기(답하기)

이름:
E-Mail:
제목:
내용:
HTML 태그 포함 여부: HTML 문서일 경우 체크
관련 URL(선택):
URL 제목(선택):
관련 이미지 URL:


[ 다음 글들 ] [ 이어서 글올리기(답하기) ] [ 자바 묻고 답하기 ]