one question in java(needed ASAP)

one question in java(needed ASAP)

Write a program which contains a main() method and a method multiplyEvens() that returns the product of the first n even integers. 

  For example:

multiplyEvens(1) returns 2

multiplyEvens(2) returns 8 (2 * 4)

multiplyEvens(3) returns 48 (2 * 4 * 6)

multiplyEvens(4) returns 384 (2 * 4 * 6 * 8)

multiplyEvens(5) returns 3840 (2 * 4 * 6 * 8 * 10)

Remark: You may NOT use a while loop, for loop or do/while loop to solve this problem; you MUST use  recursion. The method should check whether the argument is greater than 0.

  public static int multiplyEvens(int n) {

 if (n < 1) {

 throw new IllegalArgumentException();

 } else if (n == 1) {

 return 2;

 } else {

  // Fill your recursive code here

 }

  }

*Write recursive methods of the following problems and the associate test driver program. All of them are covered in class. Please refer to the class materials and lecture. 

  (1) Factorial Number : Factorial (int n) : returns n! number. 

  (2) Fibonacci : Fibonacci (int n) : returns n’th Fibonacci number. 

  (3) PowerE : PowerE (int base, int exponent) : returns the based raised to that exponent, n. 

  (4) PrintBinary : PrintBinary (int n) : returns corresponding binary number (String) of the decimal number n. 

"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.


Discount Code: CIPD30



Click ORDER NOW..

order custom paper