2011-04-09 6 views
0

일부 배열을 정렬 할 때 컴파일러에서 오류가 발생하는 데 문제가 있습니다. 나는 Arrays.sort로 그것을 또한 시도했다. 그러나, 행운이 없다.Java에서 정렬 문제

import java.util.Scanner; 
public class CH6PA 
{ 
    private static double difficulty; 
    private static int score; 
    private double[] average = new double[7]; 

    public static void main(String[]args) 
    { 
     Scanner keyboard = new Scanner (System.in); 

     do 
     { 
      System.out.println("Enter the level of difficulty (1.2-3.8)"); 
     difficulty = keyboard.nextDouble(); 
     } 
      while (difficulty<1.2 || difficulty>3.8); 


     int[] judge = new int[7]; 


     for(int i = 0; i<judge.length; i++) 
     { 
     System.out.println("Enter the difficulty score for each judge (0-10)"); 

      System.out.println("Enter the score for judge" + (i+1)); 
      judge[i]=keyboard.nextInt(); 
    while(score > 0 && score <=10); 
     } 

sort(judge, judge.length); 
System.out.println("Average = " + (judge[3] + judge[4] + judge[5])); 

} 
} 
+0

컴파일 오류가 발생했다는 것을 알려주지 않고 컴파일 오류 메시지의 내용과 오류가있는 행 *을 알려주십시오. –

+0

이것은 숙제 문제처럼 보입니다. ** 힌트 **가 완전한 답보다 더 적합하다고 가정합니다. –

답변

0

동안 (점수> 0 & &는 < 점수 = 10); 틀린 것 같습니다. 점수의 가치는 무엇입니까?

왜 while() 루프가 적용된 것처럼 두 개의 중첩 루프가 작동하지 않습니다.

0

점수에는 할당 된 값이 없으므로 null 값을 비교합니다.

0

나는 당신이 의미 믿습니다

while(score > 0 && score <=10);

은 아무 의미가 없습니다 : (컴파일 된 경우)

do { 
    System.out.println("Enter the score for judge" + (i+1)); 
    judge[i]=keyboard.nextInt(); 
} while(judge[i] > 0 && judge[i] <=10);  } 

는 지금 judge[i]

라인 stdin에서 어떤 int 읽기 것 지금 당장 컴파일러 오류가 발생합니다.