Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

New Skills to be Applied In addition to what has been covered in previous assignments, the use of the following items, discussed in class, will

New Skills to be Applied

In addition to what has been covered in previous assignments, the use of the following items, discussed in class, will probably be needed:

Recursion One-dimensional arrays

Program Description

Assignment #9 will be the construction of a program that reads in a sequence of integers from standard input until 0 is read, and store them in an array (including 0). This is done using iteration (choose one of for, while, or do while loop). You may assume that there will not be more than 100 numbers.

Then compute the minimum number, compute the largest number among the numbers that are divisible by 2, count even numbers, and compute the sum at indexes divisible by 3 (0, 3, 6, ...) using recursion. Thus you will create recursive methods findMin, computeMaxDivisibleBy2, countEvenNumbers, and computeSumOfNumbersAtIndexDivisibleBy3 in Assignment9 class and they will be called by a main method.

Specifically, the following recursive methods must be implemented (These methods should not contain any loop): public static int findMin(int[] numbers, int startIndex, int endIndex)

public static int computeMaxDivisibleBy2(int[] elements, int startIndex, int endIndex)

public static int countEvenNumbers(int[] elements, int startIndex, int endIndex)

public static int computeSumOfNumbersAtIndexDivisibleBy3(int[] elements, int startIndex, int endIndex)

If these methods are implemented using a Loop or any Static Variable, points will be deducted (from the test cases) even if your program passes test cases. DO NOT use any Static Variables.

The program should output the results of those calculations to standard output. Your program will continue to read in numbers until the number 0 is entered. At this point, the calculations will be outputted in the following format:

The minimum number is 0

The largest integer that is divisible by 2 is 0

The count of even numbers in the sequence is 0

The sum of numbers at indexes divisible by 3 is 0

Note that the result values will be different depending on test cases (not always 0).

Do not output a prompt to query for the numbers. The number 0 is included in the sequence of numbers and should be included in all of your calculations.

Input 1:

33

-55

-44

12312

2778

-3

-2

53211

-1

44

0

Output 1:

The minimum number is -55

The largest integer that is divisible by 2 is 12312

The count of even numbers in the sequence is 6

The sum of numbers at indexes divisible by 3 is 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions