Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

positive numbers in array

public class CountPositive {
    public static void main(String[] args) {
        double[] numbers = new double[4];
        numbers[0] = 1.7;
        numbers[1] = -1.9;
        numbers[2] = -5.7;
        numbers[3] = 6;
        for (int i = 0; i < numbers.length; i++) {
            if(numbers[i] > 0) {
                System.out.println(numbers[i] + " is Positive");
            }
        }
    }
}
 
PREVIOUS NEXT
Tagged: #positive #numbers #array
ADD COMMENT
Topic
Name
6+4 =