10個の整数を入力し、正、負、ゼロの個数を統計して出力します。

10個の整数を入力し、正、負、ゼロの個数を統計して出力します。

いいと思うなら、Üinclude void main(){int a[10]、i;int positivemu、negativemu、ゼロチン、positivemu=negativeunum=0;for(i=0;i 0)posivemunum+elei

javaプログラムを作成し、数不定の整数を入力し、0を入力したら終了します。これらの整数の正数と負の数を統計し、それらの合計を計算します。

public static void test(){
Scanner sc=new Scanner(System.in)
long num=0、negative=0、positive=0、sum=0
List nums=new ArayList()
ド{
System.out.println(「please enter a number」);
String s=sc.nextLine()
if(isNumber(s){
num=Long.parse Long(s)
if(num!=0){
nums.add(num)
contine;
)
break;
)
System.out.println(“not number!”);
break;
}while(true)
for(Long n:nums){
if(n>0){
positive++;
}else{
negative++;
)
sum+=n;
)
System.out.println(「the negative:」+negative);
System.out.println(「the positive:」+positive);
System.out.println(「the sum:」+sum);
)
public static book isNumber(String s){
try{
Long.parse Long(s)
return true;
}catch(Exception e){
return false;
)
)
メール関数で呼び出すだけでいいです。