1. Engineering
  2. Computer Science
  3. you are not allowed to use the scanner class in...

Question: you are not allowed to use the scanner class in...

Question details

You are not allowed to use the Scanner class in this assignment and any assignment after this one. You will need to use InputStreamReader and BufferedReader (they are in java.io package) to process input and also take care of IOException.

Assignment.java 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 sum at even indexes (0, 2, 4, ...) count numbers that are divisible by 3 and compute the maximum number among the numbers that are less than the first number (You can assume that a user will enter at least one number before 0 is entered, thus at least two numbers will be entered including 0.) using recursion. Thus you will create recursive methods findMin, computeSumAtEvenIndexes, countDivisibleBy3, and findMaxOfLessThanFirst 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 computeSumAtEvenIndexes(int[] numbers, int startIndex, int endIndex)

public static int countDivisibleBy3(int[] numbers, int startIndex, int endIndex)

public static int findMaxOfLessThanFirst(int[] numbers, int startIndex, int endIndex, int firstNumber)

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 sum of numbers at even indexes is 0

The count of numbers that are divisible by 3 is 0

The maximum number among numbers that are less than the first number 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

Test Case #1

33 -55 -44 12312 2778 -3 -2 53211 -1 44 0

Test Case #2

-10 456 23 -230 -45678 23 -10 -10 45678 -40 900 1 0

Test Case #3

222 -111 222 -555 -222 -333 111 -333 -555 0

Test Case #4

-31 -31 -31 -34 -34 -31 0 -31 -34 -34 -31

Output

Test Case #1

The minimum number is -55 The sum of numbers at even indexes is 2764 The count of numbers that are divisible by 3 is 6 The maximum number among numbers that are less than the first number is 0

Test Case #2

The minimum number is -45678 The sum of numbers at even indexes is 903 The count of numbers that are divisible by 3 is 5 The maximum number among numbers that are less than the first number is -40

Test Case #3

The minimum number is -555 The sum of numbers at even indexes is -222 The count of numbers that are divisible by 3 is 10 The maximum number among numbers that are less than the first number is 111

Test Case #4

The minimum number is -34 The sum of numbers at even indexes is -96 The count of numbers that are divisible by 3 is 1 The maximum number among numbers that are less than the first number is -34

Error Handling

Your program is expected to be robust

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution