Question: Write a program that reads in a sequence of integers from standard input until 0 is read, and stores them in an array. You may
Write a program that reads in a sequence of integers from standard input until 0 is read, and stores them in an array. You may assume that there will not be more than 100 numbers. Then compute the minimum number stored in the array, the count of odd numbers (includes both postive and negative odd integers), the number of -1 stored inside the array and compute the sum of numbers at even indexes (i.e. 0, 2, 4, ...), using recursion. Thus you will create recursive methods findMin, countOdd, countNegativeOne and computeSumAtEvenIndexes in Assignment8 class and they will be called by a main method. Specifically, the following four recursive methods must be implemented (These method should not contain any loop): //(1) It finds the minimum number in the partial array range from startIndex to endIndex public static int findMin([int[ ] numbers, int startIndex, int endIndex) //(2) It counts the number of odd integers in the partial arrya range from startIndex to endIndex public static int countOdd(int[ ] numbers, int startIndex, int endIndex) //(3 )It counts the number of -1 inside an array with "count" numbers, index ranges from 0 to count-1 public static int countNegativeOne(int[ ] numbers, int count) //(4) It computes the sum of numbers at index 0, 2, 4, ..., inside a partial array with "count" numbers inside, index ranges from 0 to count-1 public static int computeSumAtEvenIndexes(int[ ] numbers, int count)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
