Create a new C++ project titled CIS22A Lab 5 in the CodeBlocks IDE. Use the Console...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Answer rating: 100% (QA)
Here is your required code for your program Now we will discuss it Here is the editable version of t... View the full answer
Related Book For
Systems Analysis and Design
ISBN: 978-1285171340
10th edition
Authors: Shelly Cashman, Harry J. Rosenblatt
Posted Date:
Students also viewed these programming questions
-
Create a VB application that lets the user enter his or her weight (in pounds) and height (in inches). If the user fails to enter numeric values, display an appropriate error message and do not...
-
Century Lab plans to purchase a new centrifuge machine for its Manitoba facility. The machine costs $137,500 and is expected to have a useful life of eight years, with a terminal disposal value of...
-
Create the following vector A. A = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18] Then using the MATLAB's built-in reshape function create the following matrix B from the vector A: By writing one...
-
Suppose that triangle ABC is a right triangle with a right angle at C and hypotenuse c. Also note that a is the length of the side opposite angle A and b is the length of the side opposite angle B....
-
Given the stream section shown in Fig and the following measurements, calculate the total discharge throughout the section (Table). Sration 112 1615 &D 06p Measurement Station Distance Across Stream...
-
The internal rate of return from an investment in new equipment is expected to be 8.9% p.a. If the returns are expected to be $53795 at the end of the first year, -$3439 at the end of the second year...
-
A distillation column with \(6.0 \mathrm{ft}\) of packing can be operated as a stripper with liquid feed, as an enricher with vapor feed, or at total reflux. We are separating methanol from...
-
Hathaway, Inc., a resort company, is refurbishing one of its hotels at a cost of $7.8 million. Management expects that this will lead to additional cash flows of $1.8 million for the next six years....
-
69% of shares can pass an ordinary resolution on own on a poll vote
-
Fill in the missing reagents below. Me OEt ?| Br Me SH OEt OMe OEt CN
-
Example #9: The owner of The Smoke House founds that 800 people bought hamburgers as follows: Kind of Burger Frequency Relative frequency (Probability) Miniburger 140 Burger 345 Big Burger 315 Total...
-
Comment on the following: An information system is a product.
-
Does structural modeling represent classes or objects?
-
To build an information system, which do you need to identify first, classes or objects?
-
Explain the difference between requirements discovery and requirements gathering in general. Provide an example that clarifies the distinction between the two.
-
An athlete signs a five-year endorsement deal with a prominent sponsor. Under this deal the athlete will receive \($5,000\) each year for the first three years and \($6,500\) each year for the final...
-
5. (08 04) A school requires an entrance exam score that is in the top 3% of the population in order to be accepted. If an entrance exam has a mean of 500 and a standard deviation of 55, what is the...
-
The figure shows a bolted lap joint that uses SAE grade 8 bolts. The members are made of cold-drawn AISI 1040 steel. Find the safe tensile shear load F that can be applied to this connection if the...
-
What fact-finding methods are well-suited for complex technical issues? Which might be appropriate for the pursuit of new, cutting-edge features?
-
What techniques can help e-mail communications? Provide specific examples.
-
1. Should Paperback Press have a specific process to manage future changes and enhancements? What should it be? 2. If new features are added, what methodology should the IT staff use to add functions...
-
Urcarco, Inc., was a publicly held used-car dealer that had defined its market niche as customers with a low or no credit rating. In some years, Urcarcos repossession rate had run as high as 40...
-
U.S. Airways recognizes revenue from airline ticket sales when a customer takes a flight or not later than one year from the date of sale (flight coupons have a useful life of one year from the date...
-
MicroStrategy, Inc., is a software company that sells its services to other companies under multiyear contracts (on average for three years). The contracts call for a minimum fee, paid monthly, and...
Study smarter with the SolutionInn App