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

Another question on Engineering

question
Engineering, 04.07.2019 18:10
Consider a large isothermal enclosure that is maintained at a uniform temperature of 2000 k. calculate the emissive power of the radiation that emerges from a small aperture on the enclosure surface. what is the wavelength ? , below which 10% of the emission is concentrated? what is the wavelength ? 2 above which 10% of the emission is concentrated? determine the wavelength at which maximum spectral emissive power occurs. what is the irradiation incident on a small object placed inside the enclosure?
Answers: 2
question
Engineering, 04.07.2019 18:10
An air compression refrigeration system is to have an air pressure of 100 psia in the brine tank and an allowable air temperature increase of 60°f for standard vapor compression cycle temperatures of 77 f entering the expansion cylinder and 14 f entering the compression cylinder, calculate the coefficient of performance a. 2.5 b 3.3 c. 4.0 d. 5.0
Answers: 3
question
Engineering, 04.07.2019 18:20
Aquick transition of the operating speed of a shaft from its critical speed will whirl amplitude. (a) increase (b) limit (c) not affect (d) zero
Answers: 2
question
Engineering, 04.07.2019 19:20
Acommercial grade cubical freezer, 4 m on a side, has a composite wall consisting of an exterior sheet of 5.0-mm thick plain carbon steel (kst= 60.5 w/m k), an intermediate layer of 100-mm thick polyurethane insulation (kins 0.02 w/m k), and an inner sheet of 5.0- mm thick aluminium alloy (kal polyurethane insulation and both metallic sheets are each characterized by a thermal contact resistance of r 2.5 x 104 m2 k/w. (a) what is the steady-state cooling load that must be maintained by the refrigerator under conditions for which the outer and inner surface temperatures are 25°c and -5°c, respectively? (b) for power saving purpose, which wall material should be increased/reduced in. thickness in order to reduce 50% of the cooling load found in part (a)? redesign the thickness of the proposed material. 177 w/m-k). adhesive interfaces between the q=575.93 w
Answers: 2
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
question
Mathematics, 23.09.2021 22:20
question
Biology, 23.09.2021 22:20
question
Mathematics, 23.09.2021 22:20
question
English, 23.09.2021 22:20
Questions on the website: 13722361