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

  Current design model of it

In the current design model of IT service provision at NSI, the service desk function is provided in-house by TAFE employees. Consider the option of outsourcing the service desk.

  Find one article on computer or information technology

Find one article on computer or information technology

  Research various types of hard drives available from online

Research the various types of hard drives available from online and/or local retail computer stores.Make a chart of several different brands or models of 1 TB desktop hard drives.

  Government regulation in bio-engineered products

When it comes to the food industry and the bio-engineered products, is there such a thing as too much government regulation?

  Write a program that keeps names and email addresses

Write a program that keeps names and email addresses in a dictionary as key-value pairs.

  Reason for problem encounter in deleting path variables

Discuss some of the problems he may soon encounter and explain the reasons for these problems. How could he easily return path to its original value?

  Compare swing java gui components to awt components

Compare Swing Java GUI components to AWT components. Explain at least one way the components are similar and at least one way they are different. Provide examples to support your rationale.

  The args designate the range

The args designate the range [lo, hi]. If lo > hi, then that designates the empty range (no numbers), in which case outputA returns without outputting any numbers. Otherwise, outputA outputs all the numbers in the range that are interesting.

  Give a cfg for the set of all strings

Give a CFG for the set of all strings over {a,b} with twice as many a's as b's

  Develop an incident response team

Provide an overview of the organization that will be delivered to senior management, defining the business goals and objectives and the size, layout, and structure of the organization.

  Explain how that characteristic may be exploited

Describe how top-down and bottom-up methods of threat/fault analysis can be used in identifying assets relevant to a scenario. You do not need to be exhaustive but do enough of the analysis to demonstrate you understand the processes.

  How many rows will truth table require if there six variable

How many rows will a Truth Table require if there are six variables and three conditions of each variable? Defend your answer.

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