Your objective is to write a program based on recursion. Your program will ask the computer
user to enter in two numbers. You will create an if-else statement that checks if one of the two
numbers is greater than 20 then the program will print out â€œNot in range.â€
X = 2
Y = 33
Not in range.
Else your program will execute the method â€œevery2â€.
The method will be a recursion method. Your method will compose a base case and a recursive
The base case will define if x greater y and if so return 0.
X = 7
Y = 4
Now the whole objective of the code is to print the sum of every other 2 numbers the computer
user put in from 0 to 20. This means the program will add 2 to the x variable until it is greater
than the y, which will then stop the program because the base case has been reached.
If the computer user puts in 1 as the x and 11 as the y then your code should print out â€˜36â€™.
Because 1 + 3 + 5 + 7 + 9 + 11 = 36.
This will be solved in the recursion case.
o Check the user input so that it is in the range of x < 20, and y < 20.
o If the variables are within range, call the â€œevery2â€ method, a recursive method which will
add 2 to the x variable until it is larger than the y variable.
o Print out the results.