Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9894866
  • Price:- $15

Priced at Now at $15, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Question an agile-focused mind-set in project

Question: "An Agile-focused Mind-set in Project Management" • Read the following two (2) articles: "The Scrum Guide," located here and "Core Scrum," located here. Contrast the role of a Scrum Master and the role of a pro ...

Assignmentsuppose you are asked to write a program to count

Assignment Suppose you are asked to write a program to count the frequency of occurrence of each word in a document. Describe how you would implement your program using: 1. A hash table to store words and their frequenci ...

Technology certainly does play a large role in our lives

Technology certainly does play a large role in our lives and this has happened in a very short period of time. It has impacted the way we activities professionally, personally, and academically. For example, online educa ...

Create login form to enter user name and a password textbox

Create login form to enter user name and a password textbox to enter password, and write procedure to simulate the process of triggering the login process after hitting the Enter Key.

Solve the problem by implementing the whole class with main

Solve the problem by implementing the whole class with main() function and demonstrate that your Java code can pass several appropriate test cases successfully in your main() function Suppose you have a stack S containin ...

It has been a bad day for the stock market and you have

It has been a bad day for the stock market and you have heard that only 30% of all stocks gained value. Suppose you have a portfolio of 10 securities and assume a binomial distribution for the number of your stocks that ...

Subject digital securityprovide an fidm authentication

subject : Digital Security Provide an FIdM authentication system that you have used (being subjet to). Tell the name of the organizations acted as the IdP (Identity Provider) and SP (Service Provider)?

Taylor found that 8 of the recipients of loans from a

Taylor found that 8% of the recipients of loans from a particular mortgage lending institute default within the first 3 years. If he takes a random sample of 4 customers, who received loans 3 years ago, what is the proba ...

Question 1 emergency operations- a major hurricane has

Question 1: Emergency operations - A major hurricane has struck the area where your company has its central data center. There are offsite backups and hardware at three other centers around the country. - Assume that the ...

Question you have been recently promoted to lead a new

Question: You have been recently promoted to lead a new division of Company XYZ. This company is known for its team-oriented atmosphere, and your boss has raved about some of your natural leadership qualities. Your first ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As