0
이 내가 현재 가지고있는 것입니다 :테스트 점수를 누적하는 방법은 무엇입니까?
변수는 방법 지역이기 때문에 모든 값은 즉시 방법 종료와 같은 길을 잃을 것이다private void EnterBtnActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (isValidData())
{
int count = 0;
int score = Integer.parseInt(TestScoreTF.getText());
int sumScore = 0;
int sumScores = sumScore += score;
count ++;
NumberFormat nf = NumberFormat.getInstance();
NumberOfScoresTF.setText(nf.format(count));
int avgScores = sumScores/count;
AverageScoresTF.setText(nf.format(avgScores));
}
왜 'sumScore' 변수가 있습니까? 아무 목적도 가지고 있지 않습니다. –
이 전체 상황'int sumScores = sumScore + = score;'는 유효한 코드 일 수 있지만 매우 드문 경우입니다 –