Created
June 17, 2016 11:51
-
-
Save Yurlov/bef8e59d6e5ec7cf45727f9442da9fc0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ArrayPositivesCounter { | |
public static void main(String[] args) { | |
int [] array ={-3, 0, -1, 3, -2, 5}; | |
int countPositiveArray = countPositives(array); | |
System.out.println("Positive numbers in array: "+countPositiveArray); | |
} | |
private static int countPositives(int[]array){ | |
int sumPostv = 0; | |
for(int i = 0;i<array.length;i++){ | |
if (array[i]>0) { | |
sumPostv += 1; | |
} | |
} | |
return sumPostv; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment