In this assignment you are to:
#1. Write arecursivemethod:
public static int evens (int n)
that:
- accepts a positive int (n)
- prints out the even numbers between 0 and n (inclusive)
- returns the number of even numbers between 0 an n (inclusive)
#2. Write a main method that:
- accepts a positive int
- traps the user until they enter valid inout
- calls the method above
Sample input/output:
A call to evens passing it 9, evens(9)
prints out: 8, 6, 4, 2, 0 and returns 5
A call to evens passing it 4, evens(4)
prints out: 4, 2, 0 and returns 3
A call to evens passing it 21, evens(21)
prints out: 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0 and returns 11
Name your program Evens_yourInitials.java (whereyourInitials represents your initials).