Upload files to "OOP/Java/Lab/Week1"
This commit is contained in:
		
							parent
							
								
									24683dac5a
								
							
						
					
					
						commit
						8542582101
					
				
					 5 changed files with 101 additions and 0 deletions
				
			
		
							
								
								
									
										31
									
								
								OOP/Java/Lab/Week1/NumberClassify.java
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								OOP/Java/Lab/Week1/NumberClassify.java
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,31 @@ | |||
| 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."); | ||||
| 
 | ||||
|   } | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 aadit
						aadit