ii = 1; sum_x = 0; sum_x2 = 0;

x(ii) = input('first value: ');

while x(ii) >= 0
   ii = ii + 1;
   x(ii) = input('Next value: ');
end
n = ii - 1;

for ii = 1:n
   sum_x = sum_x + x(ii);
   sum_x2 = sum_x2 + x(ii)^2;
end

x_bar = sum_x/n;
sd = sqrt((n*sum_x2 - sum_x^2)/(n*(n-1)));

fprintf('Mean: %f\n', x_bar);
fprintf('SD:   %f\n', sd);
fprintf('Count:%f\n', n);

