Modify the above program to complete the same task by replacing the array with ArrayList so...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Modify the above program to complete the same task by replacing the array with ArrayList so that the user does not need to specify the input length at first. The recursion method's first argument should also be changed to ArrayList. The user input ends up with -1 and -1 is not counted as the elements of ArrayList. REQUIREMENTS ● . . ● ● The user input is always correct (input verification is not required). Your code must use recursion and ArrayList. The recursion method int addition (ArrayList<Integer> al, int start Index) is a recursion one whose arguments are an integer ArrayList and an integer, the return value is an integer. The main method prompts the user to enter the elements of the ArrayList myArrayList, calculates the addition of all elements of the array by calling the method addition (myArrayList, 0), displays the result as the following examples. Your code must work exactly like the following example (the text in bold indicates the user input). Example of the program output: Example 1: The elements of your array are: 123456-1 The addition of 1, 2, 3, 4, 5, 6 is 21. Example 2: The elements of your array are: 25 8 12 67 -1 The addition of 2, 5, 8, 12, 67 is 94. Modify the above program to complete the same task by replacing the array with ArrayList so that the user does not need to specify the input length at first. The recursion method's first argument should also be changed to ArrayList. The user input ends up with -1 and -1 is not counted as the elements of ArrayList. REQUIREMENTS ● . . ● ● The user input is always correct (input verification is not required). Your code must use recursion and ArrayList. The recursion method int addition (ArrayList<Integer> al, int start Index) is a recursion one whose arguments are an integer ArrayList and an integer, the return value is an integer. The main method prompts the user to enter the elements of the ArrayList myArrayList, calculates the addition of all elements of the array by calling the method addition (myArrayList, 0), displays the result as the following examples. Your code must work exactly like the following example (the text in bold indicates the user input). Example of the program output: Example 1: The elements of your array are: 123456-1 The addition of 1, 2, 3, 4, 5, 6 is 21. Example 2: The elements of your array are: 25 8 12 67 -1 The addition of 2, 5, 8, 12, 67 is 94.
Expert Answer:
Answer rating: 100% (QA)
Code import javautil class multiply static int multiplicationArrayList al int startIndex i... View the full answer
Related Book For
Advanced Accounting
ISBN: 978-0538480284
11th edition
Authors: Paul M. Fischer, William J. Tayler, Rita H. Cheng
Posted Date:
Students also viewed these accounting questions
-
Question 4 [7 marks] Part a) (3 marks) Calculate the statistic, set up the rejection region, draw the sampling distribution and interpret the result, Ho: H: Given that: -10, n-100, X-10, a-0.05. -10...
-
KPMG, the audit, tax, and advisory firm, has enjoyed high employee morale for the last several years about 80% of its 29,000 professionals say it is a great place to work. But the firm wanted to...
-
Why might a business be willing to consider alternative dispute resolution instead of formal litigation? Question 4 options: It is private, and it can allow involvement of mediators or arbitrators...
-
3. (15 pts.) The random variables X and Y have joint density function fxx(x, y) x-?y?, x > 1, y > 1. Compute the cdf and pdf of the random variable U = XY.
-
Describe the characteristics of a data warehouse.
-
(a) From the galvanic series (Table 17.2), cite three metals or alloys that may be used to galvanically protect 304 stainless steel in the active state.(b) As Concept Check 17.4(b) notes, galvanic...
-
On October 1, 2017, Gordon borrows \($150\),000 cash from a bank by signing a three-year installment note bearing 10% interest. The note requires equal payments of \($60\),316 each year on September...
-
Garneau Manufacturing Ltd. produces and distributes a special type of chemical compound called Compound WX. The information below about Garneaus operations has been assembled to assist budget...
-
Multiple Choice Question Managers may choose to retain an unprofitable product line because it Blank______. Multiple choice question. absorbs a share of common fixed costs is an alternative to a...
-
The return on equity (ROE) of Child SA is 14 per cent and it has a payout ratio of 0.5. Current book value per share is 50 and the book value will grow as the firm reinvests earnings. Assume that the...
-
The Brennon Group is a U.S. hedge fund that wants to benefit from the interest rate differential between the euro area and Japan. A euro () costs $1.18 today. while a yen (*) costs $0.0091 today. The...
-
The following table shows historical end-of-year prices for a stock. What is the Arithmetic average return? What is the Standard deviation? A B 1 Year Stock price 2 1 38.44 3 2 43.05 4 3 30.14 5 4...
-
Suppose you have 1000 in your bank account. The price of wheat is currently 100 per barrel. Due to unfavourable weather conditions you believe that supply will fall in the near future, however...
-
A bond with a $1,000 par, 4 years to maturity, a coupon rate of 4%, and annual payments has a yield to maturity of 4.1%. What will be the actual percentage change in the bond price if the yield...
-
1. In its most recent financial statements, Del-Castillo Inc. reported $70 million of net income and $850 million of retained earnings. The previous retained earnings were $830 million. How much in...
-
What is the yield to maturity of a 5-year, 7.5% coupon rate $1000 par value bond priced currently at $1,010? % Place your answer in percentage form using two decimal places. Do not use the percent...
-
Question 1: (Please explain your answer) (Please note all questions are for USA Federal Income Taxation) Jennifer lives and works in Tampa, FL. She travels to Paris for a four-day meeting after which...
-
State whether each statement is true or false. If false, give a reason. {purple, green, yellow} = {green, pink, yellow}
-
Pearson and Murphy have partner capital balances, at book value, of $45,000 and $65,000 as of December 31. Pearson is allocated 60% of profits or losses, and Murphy is allocated the balance. The...
-
Based on the following very limited information, indicate whether and how the city should report its related entity. 1. Its school district, although not a legally separate government, is managed by...
-
Tweeden Corporation is contemplating the acquisition of the net assets of Sylvester Corporation in anticipation of expanding its operations. The balance sheet of Sylvester Corporation on December 31,...
-
The plant managers of ABC Corporations five plants have met at a common location at 8:00 am every Monday morning for 20 years. The people serving as plant managers have changed several times during...
-
New Piper, an aircraft manufacturer, issued a Mandatory Service Bulletin grounding 76 new aircraft manufactured during the first 5 months of 2004. Thirty-nine of the airplanes were in customers...
-
Consider the logistic map discussed in the text. To gauge the density of bifurcations, one uses a measure of distance between fixed points as follows. Define \(d=x^{*}-(1 / 2)\) as the distance...
Study smarter with the SolutionInn App