Write an java application that implements two recursive


Write an Java application that implements two recursive methods in addition to the main method.

a. First Recursive Function. The first function when you pass it an integer (n for example) is supposed
to return the sum of:
1 + 1/2 + 1/3 + 1/4 + ... 1/(n-1) + 1/n

Example: if the function's argument is 4, the function should return the value of 2.083 which is the sum of 1 + 1/2 + 1/3 + 1/4.

Constraint: Must implement recursively.

b. Second Recursive Function. The second function when you pass it an integer (n for example) is supposed to print lines of asterisks in the following format:

*
**
***
****
****
***
**
*

For example: If you pass the function the number 1, it will print

*
*

If you pass the number 3

*
**
***
***
**
*

So basically given n, it will print n lines starting with one asterisk on line 1 followed by two asterisks on line 2, all the way to n asterisks on line n. Then, after line n it is supposed to print the mirror image of the first n lines printed.

Constraint: Must implement recursively.

c. Additional Guidance. You need to implement a main function in your class that will do the following:
1. Ask the user to read an integer (n)
2. Pass the integer to the first function and call it to return the sum.
3. Print the sum.
4. Ask the user to read another integer (can also be n)
5. Pass the integer to the second function to print the asterisks in the format mentioned.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Write an java application that implements two recursive
Reference No:- TGS0654234

Now Priced at $15 (50% Discount)

Recommended (92%)

Rated (4.4/5)