Loading...

one question in java(needed ASAP)

Open Posted By: roundtracker Date: 28/11/2020 Academic Level: High School Paper Type: Rewriting & Paraphrasing

Question Description

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. 


Category: Mathematics & Physics Subjects: Algebra Deadline: 24 Hours Budget: $60 - $90 Pages: 2-3 Pages (Short Assignment)