X1501: Odd Number Counter

Problem Description

Write a method countOdds that takes an ArrayList of integers and returns the count of values that are odd numbers.

public int countOdds(ArrayList<Integer> list)

Requirements

  • An odd number is any integer not divisible by 2 (i.e., num % 2 != 0).
  • Use a loop to go through each element and count how many elements satisfy this condition.

Constraints

  • The input list contain at least one integer.
  • The input list may include positive, negative numbers, and zero.

Your Answer:

Feedback

Your feedback will appear here when you check your answer.