1. Write a single program containing several methods that will compute the sum of the first...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Write a single program containing several methods that will compute the sum of the first n terms of the series in the specific manners outlined below. (Let n = 100,000 to start and if you have time, try a million terms.) a) Sum the series forwards (first term first), using type double variables and literals. b) Sum the series backwards (last term first), using type double variables and literals. sum the series forwards in two halves by computing the sum of the positive terms separately from the negative terms and then combining the results at the end. Use type double variables and literals. c) d) Sum the series backwards in two halves, computing the sum of the positive and negative terms separately, using type double variables and literals. e) Sum the series forwards (first term first), using type float variables and literals. f) Sum the series backwards (last term first), using type float variables and literals. 2. Have your program display the results from each of these methods in a table-like format, clearly labeling the output. Use 15 decimal places in your output. In a separate paragraph speculate about which result you consider the most accurate (including your calculator), and what accounts for any discrepancies, if there are any. You may also want to compare your result against the math library method log(). When you write the literal value 3.1415 Java assumes the data type is double. When you write 3.1415f you force the data type of the literal to be a float. The suffix 'f' is important when you need a literal to be a float type. I would expect the signature of each method to be of the following form: private static float sumForwards (int numberOfTerms) {...} This one satisfies le from above; each of the other methods will be similar. 1. Write a single program containing several methods that will compute the sum of the first n terms of the series in the specific manners outlined below. (Let n = 100,000 to start and if you have time, try a million terms.) a) Sum the series forwards (first term first), using type double variables and literals. b) Sum the series backwards (last term first), using type double variables and literals. sum the series forwards in two halves by computing the sum of the positive terms separately from the negative terms and then combining the results at the end. Use type double variables and literals. c) d) Sum the series backwards in two halves, computing the sum of the positive and negative terms separately, using type double variables and literals. e) Sum the series forwards (first term first), using type float variables and literals. f) Sum the series backwards (last term first), using type float variables and literals. 2. Have your program display the results from each of these methods in a table-like format, clearly labeling the output. Use 15 decimal places in your output. In a separate paragraph speculate about which result you consider the most accurate (including your calculator), and what accounts for any discrepancies, if there are any. You may also want to compare your result against the math library method log(). When you write the literal value 3.1415 Java assumes the data type is double. When you write 3.1415f you force the data type of the literal to be a float. The suffix 'f' is important when you need a literal to be a float type. I would expect the signature of each method to be of the following form: private static float sumForwards (int numberOfTerms) {...} This one satisfies le from above; each of the other methods will be similar. 1. Write a single program containing several methods that will compute the sum of the first n terms of the series in the specific manners outlined below. (Let n = 100,000 to start and if you have time, try a million terms.) a) Sum the series forwards (first term first), using type double variables and literals. b) Sum the series backwards (last term first), using type double variables and literals. sum the series forwards in two halves by computing the sum of the positive terms separately from the negative terms and then combining the results at the end. Use type double variables and literals. c) d) Sum the series backwards in two halves, computing the sum of the positive and negative terms separately, using type double variables and literals. e) Sum the series forwards (first term first), using type float variables and literals. f) Sum the series backwards (last term first), using type float variables and literals. 2. Have your program display the results from each of these methods in a table-like format, clearly labeling the output. Use 15 decimal places in your output. In a separate paragraph speculate about which result you consider the most accurate (including your calculator), and what accounts for any discrepancies, if there are any. You may also want to compare your result against the math library method log(). When you write the literal value 3.1415 Java assumes the data type is double. When you write 3.1415f you force the data type of the literal to be a float. The suffix 'f' is important when you need a literal to be a float type. I would expect the signature of each method to be of the following form: private static float sumForwards (int numberOfTerms) {...} This one satisfies le from above; each of the other methods will be similar. 1. Write a single program containing several methods that will compute the sum of the first n terms of the series in the specific manners outlined below. (Let n = 100,000 to start and if you have time, try a million terms.) a) Sum the series forwards (first term first), using type double variables and literals. b) Sum the series backwards (last term first), using type double variables and literals. sum the series forwards in two halves by computing the sum of the positive terms separately from the negative terms and then combining the results at the end. Use type double variables and literals. c) d) Sum the series backwards in two halves, computing the sum of the positive and negative terms separately, using type double variables and literals. e) Sum the series forwards (first term first), using type float variables and literals. f) Sum the series backwards (last term first), using type float variables and literals. 2. Have your program display the results from each of these methods in a table-like format, clearly labeling the output. Use 15 decimal places in your output. In a separate paragraph speculate about which result you consider the most accurate (including your calculator), and what accounts for any discrepancies, if there are any. You may also want to compare your result against the math library method log(). When you write the literal value 3.1415 Java assumes the data type is double. When you write 3.1415f you force the data type of the literal to be a float. The suffix 'f' is important when you need a literal to be a float type. I would expect the signature of each method to be of the following form: private static float sumForwards (int numberOfTerms) {...} This one satisfies le from above; each of the other methods will be similar.
Expert Answer:
Answer rating: 100% (QA)
Heres an example in Java that computes the sum of the series using the specified methods java public ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
In Problem 10.16, we projected financial statements for Walmart Stores, Inc. (Walmart) for Years +1 through +5. The data in Exhibits 12.17-12.19 (pages 948-950) include the actual amounts for 2012...
-
In Problem 10.16, we projected financial statements for Walmart Stores for Years +1 through +5. The data in Chapter 12 Exhibits 12.17-12.19 include the actual amounts for 2012 and the projected...
-
Researchers at the Hospital for Sick Children in Toronto compared babies born to mothers with diabetes to babies born to mothers without diabetes (Conditioning and Hyperanalgesia in Newborns Exposed...
-
A closely wound coil has a radius of 6.00 cm and carries a current of 250 A. How many turns must it have if, at a point on the coil axis 6.00 cm from the center of the coil, the magnetic field is...
-
In 1879, A.A. Michelson measured the velocity of light in air using a modification of a method proposed by the French physicist Foucault. Twenty of these measurements are in table 6E.27 (the value...
-
In 1940, the family of Thomas Back entered into an oil-and-gas lease with the Inland Gas Corporation. The lease held that Inland would pay to Backs family 12 cents per thousand cubic feet of gas...
-
(Long-Term Debt Disclosure) At December 31, 2010, Redmond Company has outstanding three long-term debt issues. The first is a $2,000,000 note payable which matures June 30, 2013. The second is a...
-
Mary, Shannon, and Anika each invested $9,000, $25,000, and $18,000, respectively, into a business. a. Calculate their investment ratio reduced to the lowest terms. 0 : 0 : 0
-
Largeco pension plan begins investing in VC funds in 2006. They commit to a few new funds every year. They compute returns to their VC portfolio by adding the cash flows they receive and the reported...
-
How might you engage with employees in your organization about right versus right decisions to increase mindfulness and intention? While policies may often seem like the "best" response to a dilemma,...
-
Respond to Government intervention is warranted and necessary to help save firms from going out of business. While I understand the U.S. government's reasoning for issuing the bailout to GM and...
-
During the summer months, Midway, KY, hosts Midsummer Nights in Midway. The event offers live music, shopping late at local shops, face painting, kids activities, and food vendors. One vendor sells....
-
1. One theme of this episode is that "truth heals," as Annette and April's adoptive mom states. In what ways did hidden truths create traumatic experiences for the Semaganis children?
-
Two years ago, Elizabeth Maynes took out a ten year $400,000 mortgage loan from XYZ Bank Limited at an annual interest rate of 6% compounded semiannually. ABC Bank Limited is offering an eight year...
-
The following are the Dow Jones Industrial Average's annual returns for the last five years: Year Return (%) 2017 2018 2019 2020 2021 25 -6 22 7 19 What is the arithmetic average return of the Dow...
-
Give an example of a real business organization and point out its characteristics of the type of business organization, business environment, organization structure, organizational culture. Analysis...
-
Calculate I, , and a for a 0.0175 m solution of Na 3 PO 4 at 298 K. Assume complete dissociation. How confident are you that your calculated results will agree with experimental results?
-
Fill in the blanks in each of the following statements: a) ________is a form of software reusability in which new classes acquire the members of existing classes and enhance those classes with new...
-
Some features that appear throughout Visual Studio perform similar actions in different contexts. Explain and give examples of how the ellipsis buttons, down-arrow buttons and tool tips act in this...
-
What is the key accomplishment of the UML?
-
The following are some costs incurred by a shoe manufacturer. Decide whether each one is a fixed cost or a variable cost or has some element of both. (a) The cost of leather; (b) The fee paid to an...
-
Why does the marginal cost curve pass through the bottom of the average cost curve and the average variable cost curve?
-
Outline the main factors that might influence the size of the profit mark-up set by a business.
Study smarter with the SolutionInn App