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

  Define multitasking and real-time terms of embedded system

Define, in your own words, "multitasking" and "real-time" in terms of embedded system

  Add an overloaded assignment operator

Add an overloaded assignment operator, a copy constructor to the Cube class, and a printCube member function in the attached lab6_ex2_copy_operator_starter.cpp. This starter is incomplete, you have to fill the right stuff in the blank in order to ..

  Explaining database system of facebook and google

Does Facebook and Google use same database system? Facebook seems to run with the android platform using gmail address to retain information for user such as phone numbers and contacts.

  Leading consultants for a number of patients

Doctors are specialists in some branch of medicine and may be leading consultants for a number of patients, not necessarily from the same ward.

  User defined company class

Create a user defined Company class the class will include Company Name, Stock Symbol and stock value per share. Include a parameterized constructor and get methods for each of the instance variables. Also include a toString method.

  Design a 4-bit register based on four d flip-flops

Design a 4-bit register based on four D flip-flops with three inputs I (4-bit), c (2-bit), and clk, and one output A (4-bit). The register can do four different operations depending on the value

  Which dim statement would correctly declare an array

Which Dim statement would correctly declare an array of this structure for elements having subscripts from 0 through 30

  Determine the delays of the carry out bit c48

Determine the delays of the carry out bit c48 and the gate complexity, i.e, the numbers of AND, OR and XOR gates needed for implementing the following 48-bit adders.

  Why your program should require o(logn) time per order

The double action system operates as follows. When a new buy order of $x arrives it is simply stored for future use if none of the stored sell orders has an asking price lower than or equal to $x.

  Write an application where the user to specifies

Write an application where the user to specifies the polygonal Base of a prism using the mouse. it then creates the vertex, normal, and face lists for the prism, and displays it.

  The authentication process in a synchronous token system

Describe how the Kerberos authentication process work and outline the main components within the Kerberos environment, their respective functions and the level of security provided by Kerberos. Draw a diagram supporting your explanation Explain..

  Probability and statistics for computer science

Probability and Statistics for Computer Science  - What is the probability that V will get the project and if V gets the project, what is the probability that W did not bid

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