Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Print Positives of array

import java.util.Scanner;
public class PrintPositives {
    public static void main(String[] args) {
        System.out.println("Enter size of array ");
        Scanner input = new Scanner(System.in);
        int arr = input.nextInt();
        int[] numbers = new int[arr];
        for (int i = 0; i < numbers.length; i++) {
            System.out.println("Please enter number");
            numbers[i] = input.nextInt();
        }
        System.out.println("positive numbers");
        for (int i = 0; i < numbers.length; i++) {
            if (numbers[i]>=0){
                System.out.println("positive" + "-" + numbers[i]);
            }
        }
    }
}
 
PREVIOUS NEXT
Tagged: #Print #Positives #array
ADD COMMENT
Topic
Name
1+1 =