subject
Engineering, 11.03.2020 16:57 Rock3422

You've been hired by Fruity Fillers to write a C++ console application that approximates PI. Use a validation loop to prompt for and get from the user the number of terms to approximate PI to that is between 1 and 10,000. Use the following Leibniz formula: PI approximation = 4 * (1/1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 + ...) The terms appear within the parentheses in the formula. A PI approximation to ... • One term is 4 * (1/1) = 4 • Four terms = 4 * (1/1 - 1/3 + 1/5 - 1/7) = 2.8952380952 • Seven terms = 4 * (1/1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 + 1/13) = 3.2837384837 Use a for statement that loops terms times to calculate the approximation. Each term divides one number by another: • The top number (numerator) is always 1. • The bottom number (denominator) is always an odd number. Use a variable for this that increments by two within each loop. Note from the formula that during an odd loop, we add the term to a running sum, and during an even loop, we subtract the term from a running sum. Use condition į %2=0 to determine whether a loop iteration is even or odd. Continue to use a validation loop to prompt for and get from the user the number of terms until they enter a sentinel value of 99. The overall structure of the program is: Define a constant for the numerator. Format all real numbers to ten decimal places. The output should look like this: Welcome to Fruity Fillers Enter the number of terms to approximate PI to (between 1 and 10,000, 99 to exit): 100000 Error: the number of terms must be between 1 and 10,000. Enter the number of terms to approximate PI to (between 1 and 10,000, 99 to exit): 500 PI to 500 term (s) is 3.1395926556. Enter the number of terms to approximate PI to (between 1 and 10,000, 99 to exit): 99 End of Fruity Fillers

ansver
Answers: 3

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 18:20, sarah7984
Vibration monitoring this technique uses the noise or vibration created by mechanical equipment and in seme cases by plant systems to detemine their actual condtion. a)- true b)- false
Answers: 2
image
Engineering, 04.07.2019 18:20, karatsgrande3772
Determine the damped natural frequencies and the steady state response of a decoupled damped forced two degrees of freedom system. 10ä1 + 2q1 20q1 10 cos t; 10q2 +4q2 + 40q2 10 cos t
Answers: 3
image
Engineering, 04.07.2019 19:10, netflixacc0107
What is the major difference between thermoplastics and thermosetting plastics from the polymerization structure point of view?
Answers: 2
image
Engineering, 04.07.2019 19:10, kayleeemerson77
Analyze the factors that influence the choice between the following pairs of processes to make the products indicated: i) sand casting versus die casting of an electric-motor housing ii) thread rolling versus machining of a bolt for high-strength application. (co3/c5)
Answers: 3
You know the right answer?
You've been hired by Fruity Fillers to write a C++ console application that approximates PI. Use a v...

Questions in other subjects:

Konu
History, 11.12.2021 17:40
Konu
Mathematics, 11.12.2021 17:40
Konu
English, 11.12.2021 17:40