思路:多定义几个变量记录即可。

public class Main{
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        double num1 = 0;
        int count1 = 0;
        int count2 = 0;
        while(sc.hasNextInt()){
            int temp  = sc.nextInt();
            if(temp>=0){
                num1+=temp;
                count1++;
            }
            else {
                count2++;
            }
        }
        System.out.println(count2);
        System.out.println(count1==0?0.0:String.format("%.1f", num1/count1));
    }
}