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 15:10
Two flowing streams of argon gas are adiabatically mixed to form a single flow/stream. one stream is 1.5 kg/s at 400 kpa and 200 c while the second stream is 2kg/s at 500 kpa and 100 ? . it is stated that the exit state of the mixed single flow of argon gas is 150 c and 300 kpa. assuming there is no work output or input during the mixing process, does this process violate either the first or the second law or both? explain and state all your assumptions.
Answers: 1
question
Engineering, 04.07.2019 18:10
Aflywheel accelerates for 5 seconds at 2 rad/s2 from a speed of 20 rpm. determine the total number of revolutions of the flywheel during the period of its acceleration. a.5.65 b.8.43 c. 723 d.6.86
Answers: 2
question
Engineering, 04.07.2019 18:10
Asingle-geared blanking press has a stroke of 200 mm and a rated capacity of 320 kn. a cam driven ram is assumed to be capable of delivering the full press load at constant force during the last 15 percent of a constant-velocity stroke. the camshaft has an average speed of 90 rev/min and is geared to the flywheel shaft at a 6: 1 ratio. the total work done is to include an allowance of 16 percent for friction a) estimate the maximum energy fluctuation b) find the rim weight for an effective diameter of 1.2 m and a coefficient of speed fluctuation of 0.10
Answers: 1
question
Engineering, 04.07.2019 18:10
Ifa component is made of two or more materials with different modulus of elasticity (e), it is called a composite member and we calculate the factor·n". mention the formula for calculating n". also, ifn> 1, explain what will happen to the 1. transformed.gi) ifn 1, what will happen to the material when transformed material when
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, 16.08.2020 01:01
question
Mathematics, 16.08.2020 01:01