Code:
import java.io.*;
import java.lang.*;
import java.util.Scanner;
class count
{
public static void main(String args[])throws IOException
{
int a,i,p,j,k,count=0;
int[] h= new int[50];
Scanner in=new Scanner(System.in);
System.out.println("insert numbers");
p=in.nextInt();
for( i=0;i<p;i++)
{
System.out.println("enter your value "+i);
h[i]=in.nextInt();
count++;
}
int odd=0,even=0,postive=0,negative=0;
for(j=0;j<count;j++)
{
if(h[j]%2==0)
{
even++;
}
else
{
odd++;
}
}
for(k=0;k<count;k++)
{
if(h[k]<0)
{
negative++;
}
else
{
postive++;
}
}
System.out.println("There are " +odd +" odd numbers");
System.out.println("There are " +even +" even numbers");
System.out.println("There are " +postive +" postive numbers");
System.out.println("There are " +negative +" negative numbers");
}
}
No comments:
Post a Comment