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
-
Construct an entire function that has simple zeros at the Gaussian integers m + ni,
-
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...
-
Imagine that LTSC called you in as a consultant before Watanabe started his sabbatical. The agency has asked you to help obtain the maximum developmental benefit from the sabbatical arrangement. How...
-
Logan Products has two production departments-assembly and finishing. These are supported by two service departments-sourcing (purchasing and handling of raw materials and human resources) and...
-
What are information quality and environmental quality? Are they related? Why is low-quality information said to drive out high-quality information?
-
On January 1, 2012, Quinton Corporation issued $600,000 of 7% bonds that are due in 10 years. The bonds were issued for $559,229 and pay interest each July 1 and January 1. The company uses the...
-
The Punch Bowl Corp. produces and sells two products, P and B. In prior year, Punch Bowl has sold 3 units of product P for every unit of product B. Selected data on these products show the following:...
-
1. XYZ Ltd. ("XYZ") yesterday issued a $1,000 par value 5 year bond ("the Bond"), In evaluating any capital budgeting proposal, XYZ has, historically, utilized a Required Rate of Return of 25%. As a...
-
Question 3. Suppose 5 friends from UArizona want to attend a Wildcats football game. Alice values a ticket at $15, Ben values a ticket at $12, Chase values a ticket at $18, Dan values a ticket at...
-
BIG Construction (BC) is building a bridge for $40 million at a total cost of $34 million over the next three years. The company uses percentage of completion method to recognize revenue. Below is a...
-
The same four friends buy tickets for two shows on consecutive nights. They use a coupon for $5 off each ticket. They pay a total of $416 for 8 tickets. Write and solve an equation to find the...
-
You would like to have $200,000 in a college fund in 15 years. How much do you need today if you expect to earn 12% while you are investing to pay for your child's college?
-
Describe an experience when you communicated with someone that you thought were charismatic. What were some of the qualities that you were most impressed with? How did the individual influence you to...
-
Jeremy Pruitt Ltd is considering the replacement of a delivery truck. The current truck could last for three more years. Operating costs are 5000 per year. We are currently depreciating it at 4000...
-
Consider the function T : R R, defined by T(x, y, z) = (x + 3y, 2x + 5z) (a) Write the matrix for T. (b) For the vectors u = (1,5,-2), v = (2, 7, 4) = R, verify that T(2u+ 3v) = 2T(u) + 3T(v). (c)...
-
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?
-
Which one of the following is an exact straight line mechanism using lower pairs? (a) Watt's mechanism (b) Grasshopper mechanism (c) Robert's mechanism (d) Peaucellier's mechanism.
-
In the epicyclic gear train shown in the Fig. \(88, T_{A}=40, T_{B}=20\). For three revolutions of the arm, the gear \(B\) will rotate through (a) 6 revolutions (b) 2.5 revolutions (c) 3 revolutions...
-
Which one of the following statements in respect of involute profiles for gear teeth is not correct? (a) Interference occurs in involute profiles (b) Involute tooth form is sensitive to change in...
Study smarter with the SolutionInn App