CSE205 Assignment #9 Solved

25.00 \$

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . ` zip` solution files instantly, after Payment

Description

5/5 - (1 vote)

Minimal Submitted Files

You are required, but not limited, to turn in the following source files:

Assignment9.java

Requirements to get full credits in Documentation

1. The assignment number, your name, student ID, lecture number/time, and a class description need to be included at the top of each file/class.
2. A description of each method is also needed.
3. Some additional comments inside of methods (especially for the “main” method) to explain codes that are hard to follow should be written.

You can look at the Java programs in the text book to see how comments are added to programs.

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

The following files are the test cases that will be used as input for your program (Right-click and use “Save As”):

Output

The following files are the expected outputs of the corresponding input files from the previous section (Right-click and use “Save As”):

Error Handling

Your program is expected to be robust enough to pass all test cases.

• Assi9.zip