-2
嗨,我想知道是否有人可以解釋如何使這種方法顯示運行計數和平均值,而不是隻要用戶輸入完數據就顯示出來?Display running total
public void InScreen()
{
int count = 0;
double total = 0.0;
double average = 0.0;
double number;
Console.WriteLine("Enter the set of scores (enter 0 to indicate end of set)");
number = double.Parse(Console.ReadLine());
while(number != 0)
{
total += number;
count++;
number = double.Parse(Console.ReadLine());
}
if (count != 0)
average = total/count;
Console.Beep(20000, 2000);
Console.WriteLine("The user has entered {0} scores.", count);
Console.WriteLine("The sum of scores entered = {0}", total);
Console.WriteLine("The average of scores entered = {0}", average);
}
請接管你如何展示你的代碼更加小心。沒有縮進,它真的很難閱讀。接下來,你有什麼*嘗試*顯示運行計數和平均值?提示:你會在'while'循環中寫出輸出... –
所以,只需在while循環中移動你的彙總代碼 – musefan
謝謝對不起回合,更容易然後我認爲它會是 –