請幫我弄清楚我的錯誤。當我按照4,5的升序輸入分數時,最小值爲100.我不知道如何改變它?使用Java查找最小和最大值
這裏是我的代碼:
float score=0,min=100,max=0,sum1=0,count=0,sum2=0;
float average,sd;
Scanner a=new Scanner(System.in);
while(score>=0)
{
System.out.println("enter the score(a negative score to quit)");
score=a.nextInt();
if(score<0)
break;
if(score>=max){
max=score;
sum1+=max;
}
else
{
min=score;
sum2+=min;
}
count++;
}
average=(sum1+sum2)/(count++);
System.out.println("the average : " + average);
System.out.println("the maximum score: "+ max);
System.out.println("the min score: "+ min);
我剛剛檢查了你的code.its仍然是相同的minimum.no changes.um .. – vini