This assignment does not exactly match the one in the textbook on which it is based.  I don't want any counter-controlled loops in your solution.  Your solution should be able to detect when the accuracy isn't improving and then display the results of the work (as outlined below): Look at Programming Exercise **5.25 in the textbook on approximating the value of π.  It is described as: π = 4 (  1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 + ... + (-1)^(i+1)/(2i-1) ) Notice that Java has the best possible value of π that can be stored as a type double available as Math.PI (part of the java.lang package). See how close you can get to the best value of π using a loop with the above technique. Notice that the above implies you are testing the value of your own estimate as it approaches the best value available in Java (as a type double).  This would not be a pre-determined, counter-controlled loop.  You are testing the results (sentinel-controlled) until you reach a value with the minimum discrepancy against Math.PI.  If done correctly, you can get full credit but you will have trouble.  The point of this assignment is to illustrate the difficulty of implementing some pure-math algorithms with digital computing resources.  The goal is to have you experiment and notice the results of your various efforts.  While gaining the credit is easy, getting the best results is not. How many iterations did it take? How far off was your estimated value. Attach the source code (as a single dot java file) and include in the output your calculated value, the number of iterations it took and the discrepancy.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 14PE
icon
Related questions
Question

This assignment does not exactly match the one in the textbook on which it is based.  I don't want any counter-controlled loops in your solution.  Your solution should be able to detect when the accuracy isn't improving and then display the results of the work (as outlined below):

Look at Programming Exercise **5.25 in the textbook on approximating the value of π.  It is described as:

π = 4 (  1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 + ... + (-1)^(i+1)/(2i-1) )

Notice that Java has the best possible value of π that can be stored as a type double available as Math.PI (part of the java.lang package).

See how close you can get to the best value of π using a loop with the above technique.

Notice that the above implies you are testing the value of your own estimate as it approaches the best value available in Java (as a type double).  This would not be a pre-determined, counter-controlled loop.  You are testing the results (sentinel-controlled) until you reach a value with the minimum discrepancy against Math.PI.  If done correctly, you can get full credit but you will have trouble.  The point of this assignment is to illustrate the difficulty of implementing some pure-math algorithms with digital computing resources.  The goal is to have you experiment and notice the results of your various efforts.  While gaining the credit is easy, getting the best results is not.

How many iterations did it take?
How far off was your estimated value.

Attach the source code (as a single dot java file) and include in the output your calculated value, the number of iterations it took and the discrepancy.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning