Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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

image text in transcribed
image text in transcribed
(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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Strategic Database Technology Management For The Year 2000

Authors: Alan Simon

1st Edition

155860264X, 978-1558602649

More Books

Students also viewed these Databases questions