2010-10-02 74 views
0

我只是試圖計算一些東西。我所有的輸入都是int。如何計算?

int aveScore = (startScore/((([p1.arrayThrow count]-1)) + winPane.throws)); 

結果是(對於startscore = 501,其餘= 3 [三分之五百○一= 167])100。即使試圖float aveScore這導致類似10359.此外沒有工作:

int aveScore = (float) ... 

這裏有什麼問題?

回答

0

int aveScore = (int)((float)startScore/(([p1.arrayThrow count] - 1) + winPane.throws));

編輯:

如果你想有一個浮點平均得分那麼這將僅僅是:

float aveScore = (float)startScore/(([p1.arrayThrow count] - 1) + winPane.throws);

+0

的結果是一樣的:100。但無論如何,我我已經忘記告訴我,我想把結果當成一個浮動。應該像'float aveScore =(float)...'但工作:/ – lueda 2010-10-02 17:24:08