MIT-Curricular/OOP/Java/Lab/Week1/NumberClassify.java

31 lines
727 B
Java
Raw Normal View History

2024-08-05 01:06:30 +05:30
import java.util.Scanner; // Import the Scanner class
class NumberClassify {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int i,pos=0,zero=0,neg=0;
int[] arr;
arr = new int[10];
System.out.println("Enter 10 Numbers:");
for(i=0;i<10;i++){
arr[i] = sc.nextInt();
}
for(i=0;i<10;i++){
if(arr[i] > 0){
pos++;
}else if(arr[i] < 0){
neg++;
}else{
zero++;
}
}
System.out.println("There are "+pos+" positive numbers.");
System.out.println("There are "+neg+" negative numbers.");
System.out.println("There are "+zero+" zero values.");
}
}