Methods in addition to the main method

Assignment Help Basic Computer Science
Reference no: EM13315554 , Length: 1 page

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.

Reference no: EM13315554

Questions Cloud

The new office manager for the family practice medical group : The new office manager for the Family Practice Medical Group
Important element in the speech preparation process : Organization is an important element in the speech preparation process. What do you need to take into consideration when organizing your speech material?
What specific interpersonal skills does person possess : Think of someone in your workplace (or previous workplace, organized club or activity, etc.) who you consider to have effective interpersonal communication skills on the job. What specific interpersonal skills does this person possess? How do t..
Important to give credit to the author of the work : Directions: It is important to give credit to the author of the work you are using to prevent plagiarizing. For this assignment, you are going to complete an exercise to properly cite 5 sources in proper APA format. Using the following informa..
Methods in addition to the main method : Write an Java application that implements two recursive methods in addition to the main method.
Write appropriate methods : Write a program that can be used to determine the tip amount that should be added to a restaurant  charge.
How cultural values affect moral legitimacy : Identify examples of how cultural values affect moral legitimacy
Research-based proposal essay : I am having a lot of trouble picking a topic for my research-based proposal essay. I need to write a proposal essay in the format of A should do B because of C such as Our Student government should endorse the Academic Bill of rights because students..
Concept of quality in strategy formulation : How important is the concept of quality in strategy formulation and justify your answer by referring to examples from reknown company or a company you know well.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Business requirements drove the system''s initial development

Discuss how the business requirements drove the system's initial development. Describe the type and basic uses of the system, how the system has helped the organization, and any likely future development plans.

  How has the progression of communication technology

How has the progression of communication technology affected the business environment?

  Use a joptionpane to ask the user

Write a Java application which tests the random number generation abilities of Java. Random number generation is explained below.Your application should simulate rolling a pair of dice some number of times.

  Use double variable to represent the private data of class

Use double variable to represent the private data of the class. Provide a constructor that enables an object of this class to be initialized when it is declared.

  How many outcomes have at least one 1

In this version, there are C(6+3-1,3) = 56 different outcomes in Chuck-a-Luck. Order doesn't matter, just the number's that come up. Out of those 56, how many outcomes have at least one 1?

  Create two files edit your new file using gedit vi and chage

Create two files. • File1 has one line with the value of 5. • File2 has one line with the value of 100. Edit your new file using Gedit or VI and change it so it performs the following actions

  Express problem as ilp constraints

Each will receive exactly 7. Additionally, each individual must receive the same quantity of wine. Express the problem as ILP constraints, and find a solution.

  How would you display the man page for shadow

How would you display the man page for shadow in section 5 of the system manual?

  Which library procedures issue system calls

With respect to a programmer, a system call looks the same as a call to a library procedure. Is a programmer required to identify which library procedures issue system calls? Explain your answer.

  Write a java code which acts as a calculator

Can someone write this code for me really quick. Write a java code which acts as a calculator. I have two text fields.

  Describe areas where you disagreement between sources

IT engagement model and management. Include any information you believe adds to the material in the text. Describe any areas where you see disagreement between the sources.

  Compute the number of different possible ways

Compute the number of different possible ways in which the instructions of the two processes can be interleaved when the two processes are executed concurrently.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd