2017-09-01 7 views
-3

このエラーメッセージが表示され続けるので、その意味や対応方法がわかりません。私のコードをheres。私は別のコンパイラに行くとき、私はこの問題を取得しないでください。前もって感謝します!メイン(Eclipse)の未解決のエラー

import java.math.*; 
import java.util.*; 

public class QuestionEight { 

    public QuestionEight() { 
     // TODO Auto-generated constructor stub 
    } 

    public static void main(String [] args) { 
     // TODO Auto-generated method stub 
     int[] newArr = new int[1000]; 
     for(int a = 0; a<1000; a++) { 
      newArr[a] = countNumbers(); 
     } 
     double sum = (double)sumOfArray(newArr); 
     double attempts = (double)1000; 
     System.out.println("The average is " + sum/attempts); 
    } 
    public static int countNumbers() { 
     int sum = 0; 
     int counter = 0; 
     while(sum<1) { 
      sum = Math.floor(10.0*Math.random()); 
      counter++; 
     } 
     return counter; 
    } 
    public static int sumOfArray(int[]a) { 
     int[] tempArr = new int[a.length]; 
     for(int c = 0; c<a.length; c++) 
      tempArr[c] = a[c]; 
     for(int d = 1; d<a.length; d=d+2) { 
      tempArr[d] = tempArr[d] + tempArr[d-1]; 
      if(d==tempArr.length-1) { 
       return tempArr[d]; 
      } 
     } 
     return 0; 
    } 
} 
+1

これは文字通り、すべてのエラーテキストです。また、それは配列を合計する奇妙な方法です... –

+1

"別のコンパイラ"とはどういう意味ですか? –

+0

BlueJで動作します。そして、ええ、それは基本的に私が持っているすべてのエラーテキスト –

答えて

0

あなたのコードは、あなたがMath.floorタイプdoubleの値を返しますので、

sum = (int) Math.floor(10.0 * Math.random()); 

sum = Math.floor(10.0 * Math.random()); 

を変更したい場合がありますことを除いて、正常に見えます。

関連する問題