package nameyu; import java.util.Scanner; public class Test { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub System.out.print("Enter an integer, the input end if it is 0:"); Scanner input=new Scanner(System.in); // int n=input.nextInt(); double sum=0,ave; int positive=0,negative=0,count=0; int n=input.nextInt(); while(n==0){ System.out.println("nonononono"); break; } while(n!=0){ sum+=n; ++count; if(n>0){ positive++; }else negative++; n=input.nextInt(); ave=sum/count; System.out.println("The number of positives is "+positive); System.out.println("The number of negatives if "+negative); System.out.println("The total is "+sum); System.out.println("The average is "+ave); } } }
|