✔ 最佳答案
不太明白你的問題,亦不太清楚你所需要的東西,答錯不要見怪^^
其實你要用咩language寫,在那裡執行(電腦??計數機??)
用pascal的方式寫個program讓你參考,你可嘗試把它轉換你所用的語言.
program doubleOfMean;
var sumUp, mean, doubleMean, tempNum : real;
tempNumString, errorPosition : string;
icounter : integer;
begin
icounter := 0;
repeat
mean := 0.0;
doubleMean := 0.0;
sumUp := 0.0;
write('Please input number, input 'exit' to calculate DOUBLE of MEAN. ');
readln(tempNumString);
if tempNumString <> 'exit' then begin
val(tempNumString, tempNum, errorPosition); {Change the string to number}
sumUp := sumUp + tempNum;
icounter := icounter + 1;
end;
until (tempNumString = 'exit'); {exit the repeat-until loop if the user input 'exit'}
mean := sumUp / icounter; {Calculate the mean}
doubleMean := 2.0 * mean;
writeln('Double Mean is : ', doubleMean); {Display the result}
end.