Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

To be written after paper and pencil test is turned in. You may not consult other files saved on your computer for this part of

image text in transcribed
To be written after paper and pencil test is turned in. You may not consult other files saved on your computer for this part of the test. You may write this entire program in function main although functions are certainly permissible. The value of pi(Pi) can be estimated by the following formula for m+1 terms: pi approximately squareroot 12 Sigma^m_n=0 (-3)^-pi/(2n + 1) where n = 0, 1, 2, ellipsis m Thus the sum in the approximation is (-3)^0/(2*0+1) + (-3)^-1/(2*1+1) + ellipsis + (-3)^-m/(2*m+1) a. Write a program that uses this formula to calculate pi. In function main prompt the uses for the number of terms to be used in the approximation. Restrict the number of terms to an integer between 10 and 40 (including 10 and 40) terms by using a while or do ellipsis while data validation loop. Then calculate the approximation value for pi, using a for loop for the sum. Print the approximation with 6 decimal digits. b. In the same program create a table of radius values from 2 to 20 at intervals of 2 and corresponding circle circumferences (C = 2 pi r), using the value of pi from the approximation formula found in part a. (If you could not get part a to work, you may use 3.14159 as the value of pi for this part.) Use integers for radius and floats for circumference values. Place column headings above the table and print radius values in the column on the left with 0 decimal digits and circumferences in the column on the right with 2 decimal digits

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

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions