package demo;
import java.util.Scanner;
public class Mean {
double count=0;
double j =0;
public void value( ) throws Exception {
Scanner sc =new Scanner(System.in);
System.out.println("输入想要添加的一个数:");
double i =sc.nextDouble();
if( i>=0 ) {
j+=i;
count++;
System.out.println("平均数为:"+(j/count));
System.out.println("输入了第:"+count+"次");
value();
}else {
throw new Exception("参数不能为负数");
}
}
public static void main(String[] args) throws Exception {
Mean y = new Mean ();
y.value();
}
}