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, 03.07.2019 14:10
If the thermal strain developed in polyimide film during deposition is given as 0.0044. assume room temperature is kept at 17.3 c, and thermal coefficient of expansion for the film and the substrate are 54 x 10^-6c^-1 and 3.3 x 10^-6c^-1respectively. calculate the deposition temperature.
Answers: 3
question
Engineering, 04.07.2019 18:10
Adouble-strand no. 60 roller chain is used to transmit power between a 13-tooth driving sprocket rotating at 300 rev/min and a 52-tooth driven sprocket. a) what is the allowable horsepower of this drive? b) estimate the center-to-center distance if the chain length is 82 pitches. c) estimate the torque and bending force on the driving shaft by the chain if the actual horsepower transmitted is 30 percent less than the corrected (allowable) power.
Answers: 3
question
Engineering, 04.07.2019 18:10
Items are similar to the free issue items, but their access is limited. (clo5) a)-bin stock items free issue b)-bin stock controlled issue c)-critical or insurance spares d)-rebuildable spares e)-consumables
Answers: 1
question
Engineering, 04.07.2019 18:10
Compute the pressure drop of 30°c air flowing with a mean velocity of 8 m/s in a circular sheet-metal duct 300 mm in diameter and 15 m long. use a friction factor, f 0.02, and pair = 1.1644 kg/m a. 37.26 pa b. 25.27 pa n c. 29.34 pa d. 30.52 pa
Answers: 1
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, 07.01.2020 15:31
question
English, 07.01.2020 15:31
question
Mathematics, 07.01.2020 15:31
question
Mathematics, 07.01.2020 15:31
Questions on the website: 13722363