Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a new C++ project titled CIS22A Lab 5 in the CodeBlocks IDE. Use the Console Application project option. Use loop to approximate the

image

Create a new C++ project titled "CIS22A Lab 5" in the CodeBlocks IDE. Use the "Console Application project option. Use loop to approximate the Pl value In the 14th century, Babylonian mathematicians approximated the value of PI manually by calculating this series: 12 (1-3-3) + Each term in the series has this common pattern: 12 x 1/(m x3") where m is 1, 3, 5, 7......... and n is 0, 1, 2, 3, 4....... 1 1 5.32 7.33 The first term in the series has the value 12 where m is 1 and n is 0. 12 * The second term has the following value, where m is 3 and n is 1: -1 3x3 ...) Notice that the signs of each term alternate between + and - The program should ask user to enter the number of terms (termCount) for the series. The program then iterates termCount times to estimate the PI value and display it. The larger the input termCount is, the more accurate the value of estimated Pl is. Topic: Use of any loop statement (chapter 5). There is NO need to use any "if/else" statement. https://docs.google.com/document/d/1zbSZh6ldyge7lauROojEfg0_slyCPYXCEXL8tz2iht0/edit?usp=sharing You should use an input validation loop to ensure that user enters a value of termCount that is greater than 0. If user enter a count that is less than 0, keep asking for another input. The program should display the estimated Pl value with 15 decimal digits in the fractions. You should use the square root function and power function in the "cmath" library. You should also display the value of the M_PI constant in the C++ "cmath" library with 15 decimal fraction digits after decimal point. Displaying both the calculated value and the C++ M_PI constant provides an easy way to compare and see the difference. Here are sample outputs: This program estimates the value of PI using the Babylonian method. Enter a count that will be used for series iteration: 1 1 3.464101615137754 Estimated PI with 15 decimal fraction digits is 3.464101615137754 PI value in the cmath library is 3.14159265 35 89793 Process returned 0 (0x0) execution time: 2.595 s Press any key to continue. This program estimates the value of PI using the Babylonian method. Enter a count that will be used for series iteration: 10 1 3.464101615137754 2 3.079201435 678004 3 3.156181471569954 4 3.137852891595680 5 3.142604745663084 6 3.141308785462883 7 3.141674312698837 8 3.1415687159 9 3.141599773811505 10 3.141590510938080 84 Estimated PI with 15 decimal fraction digits is 3.141590510938080 PI value in the cmath library is 3.141592653589793 Process returned 0 (0x0) Press any key to continue. execution time: 11.348 s

Step by Step Solution

3.45 Rating (155 Votes )

There are 3 Steps involved in it

Step: 1

Here is your required code for your program Now we will discuss it Here is the editable version of t... 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

Step: 3

blur-text-image

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

Systems Analysis and Design

Authors: Shelly Cashman, Harry J. Rosenblatt

10th edition

1285422708, 1285171349, 9781285422701, 978-1285171340

More Books

Students also viewed these Programming questions