Write a program that creates an array of at least 20 integers and do the following: Prompt

Question:

Write a program that creates an array of at least 20 integers and do the following:
❯❯Prompt the user for a starting position, and continually reprompts the user for a new value if the starting position is less than 0 or greater than the highest allowed subscript for the array.
❯❯Prompt the user for an ending position, and continually reprompt the user for a new value if the ending position is not greater than or equal to the starting position and less than or equal to the highest allowed subscript for the array.

❯❯Display all the values in the requested range of the array.
❯❯Include a recursive method that sums all the values in the requested range. The method accepts the array, the starting position, and the ending position. The base case occurs when the starting position is greater than the ending position; if so, the method returns 0. Otherwise, the recursive cases return the value at the current starting position plus a new call to the method. The three arguments passed to the new method call are the array, the current starting position plus one, and the ending position. Save the program as SumRangeRecursively.java.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  answer-question

Java Programming

ISBN: 9780357673423

10th Edition

Authors: Joyce Farrell

Question Posted: