原题,从键盘一直输入int 数字,输入0则退出程序,退出时统计正数和负数的个数。 package test;//包名
import java.util.Scanner;//导入Scanner
public class DoWhileTest { public static void main(String[] args) {
Scanner sca = new Scanner(System.in);//创建对象
int countU = 0;//正数计数器
int countL = 0;//负数计数器
while (sca.nextInt() != 0){//若输入值不为0
if (sca.nextInt() > 0)
{
countU ++;//输入正数,计数器加1
}
else
{
countL ++;//输入负数,计数器加1
}
}
System.out.println("U is " + countU +"L is " + countL); //输出正数和负数的个数
}
}



