Question: Write a well-documented (commented) java program, NumbersRangeSum, that computes the sum of natural numbers in a given range entered by the user. Notes: Assume that
Write a well-documented (commented) java program, NumbersRangeSum, that computes the sum of natural numbers in a given range entered by the user.
Notes: Assume that the given range would include the starting and ending numbers (i.e., it would be a closed range on both ends). Natural numbers are defined as 1, 2, 3, 4, and so forth The sum is returned by the method.
The program should have a static recursive method, getSum that takes two natural numbers as arguments and computes the sum recursively. The sum is returned by the method. This static method would be called by the main method. Sample runs would be as follows.
>java NumbersRangeSum 6 10
The sum of natural numbers in range [6,10] is 40.
>java NumbersRangeSum 13 20
The sum of natural numbers in range [13, 20] is 132.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
