id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us introtoarrays > countPosEven
prev  |  next  |  chance

Write a method that has a non-empty array of integers as an input parameter. The method returns the number of even integers in the array that come before the first non-positive number in the array. For example: countPosEven({3, 17, 26, 1, -9, 4, 2, 8}) returns 1 because there is only one even integer


countPosEven([5, 7, 8, 3, 11, 0, 6, 10, 4, -5, 8, 12]) → 1
countPosEven([10, 14, 2, 7, 5, 8, -4, 6, 100, 44, 6]) → 4
countPosEven([7, 5, 33, 57, -6, 12, 80, 5]) → 0

...Save, Compile, Run (ctrl-enter)

public int countPosEven(int[] nums) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 330

Copyright Nick Parlante 2017 - privacy