[java]代码库
import java.util.Scanner;
public class lian114_11 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int sum=0;int total=0;int number1=0;int i;
int number2=0;
Scanner input=new Scanner(System.in);
System.out.print("Enter an int value,the program exits if the input is 0:") ;
i=input.nextInt();
while(i!=0){
total=total+i;
// System.out.print("Enter an int value,the program exits if the input is 0") ;
// i=input.nextInt();
if(i>0){
number1++;
}
else if(i<0){
number2++;
}
System.out.print("Enter an int value,the program exits if the unput is 0:") ;
i=input.nextInt();
}
double average=(double)total/(number1+number2);
System.out.println("The number of number1:"+number1);
System.out.println("The number of number2:"+number2);
System.out.println("The number of total:"+total);
System.out.println("The average:"+average);
}
}
初级程序员
by: 云代码会员 发表于:2016-06-09 23:02:35 顶(0) | 踩(0) 回复
我要积分啊!
回复评论