Question: (FirstOddoccurence) Add a method, firstOddCount, to the given program stub that receives an array of int, and returns the number of times the first odd

(FirstOddoccurence) Add a method, firstOddCount, to the given program stub that receives an array of int, and returns the number of times the first odd integer appears in the array. If no odd integer is in the array, the function returns a zero. Example: x 2 4 6 7 4 3 2 7 6 77 firstddCount(x) will return 4, since 7 is the first odd integer and it appears 4 times in the array Sample Output: 3, 2, 7, 6, 7, 7 Array: 2, 4, 6, 7, #Occurrences of first odd - 4 import java.util.*; public class FirstOddoccurrence { public static void main(String[] args) { int[] x = { 2, 4, 6, 7, 4, 3, 2, 7, 6, 7, 7 }; int i; display(x): System.out.printf("# Occurrences of first odd = %3d ", firstOddCount(x)); } private static void display( int[] x) { int i; System.out.print("Array: "); for(i=0; i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
