Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using the Java programming language, calculate the value of pi from the infinite series pi = 4 - 4/3 + 4/5 - 4/7 + 4/9

Using the Java programming language, calculate the value of pi from the infinite series pi = 4 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11 + ... Print a table that shows the value of pi approximated by computing one term of this series, by two terms, by three terms, and so on. Use default precision for output (i.e. do not set any decimal precision). Start by asking the user how many terms of the series to compute to, and then let the user enter the information. Use this to print a table of the first N terms of the series (where N is the data entered by the user). Assume the user's input will be a non-negative integer. (see sample output)

Sample Run (Sample user input is bolded)

Exercise 5.20: 'Approximating PI'

Compute to how many terms of the series? 20 terms

PI approximation

1 4.0

2 2.666666666666667

3 3.466666666666667

4 2.8952380952380956

5 3.3396825396825403

6 2.9760461760461765

7 3.2837384837384844

8 3.017071817071818

9 3.2523659347188767

10 3.0418396189294032

11 3.232315809405594

12 3.058402765927333

13 3.2184027659273333

14 3.0702546177791854

15 3.208185652261944

16 3.079153394197428

17 3.200365515409549

18 3.0860798011238346

19 3.1941879092319425

20 3.09162380666784

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What are the antecedents and outcomes of virtuous leadership?

Answered: 1 week ago

Question

(a) There are five factors (A, B, C, D, and E). Pg45

Answered: 1 week ago

Question

selection control with java differential piecework schedule

Answered: 1 week ago

Question

1. Write down two or three of your greatest strengths.

Answered: 1 week ago

Question

What roles have these individuals played in your life?

Answered: 1 week ago

Question

2. Write two or three of your greatest weaknesses.

Answered: 1 week ago