%Computes the average of non negative numbers until the first negative number is enter by the user

s=0;
n=0;
 
term=input('Give the first number: ');
while term>=0
      s=s+term; 
      n=n+1;
      term=input('Please give the next number: ');
end

if n==0
    disp(' ')
    disp('You need to enter at least one nonnegative real number.')
    disp('Please try again')
else
    disp(' ')
    disp(['The average of the non negative numbers is ', num2str(s/n)])    
end
