Question: 1 of You will write a program to compute some statistics about boxes of a popular breakfast cereal called Chocolate Frosted Sugar Bombs manufactured by
1 of You will write a program to compute some statistics about boxes of a popular breakfast cereal called "Chocolate Frosted Sugar Bombs" manufactured by the General Junkfoods Corporation. Automated machinery is used at the company's factory to fl individual boxes with cereal. No machine is perfect, so the amount of cereal actually in a box will vary slightly from box to box. The data file OFSB.xt on the class website gives the weight (in ounces) of the last 1,000 boxes of Chocolate Frosted Sugar Bombs produced in the factony For every box in this sample that weighs less than the advertised 20 ounces, General Junidoods will incur a $250,000 fine. The statistics you must compute in your program are: . The average weight of the "20 ounce" boxes of cereal. The standard deviation of the sample (see below) The number of boxes below the advertised weight of 20 ounces The fine owed by the company for the underweight boxes. The maximum value of the weights of the 1,000 boxes * The minimum value of the weights of the 1,000 boxes. Input: Your program should ask the user for the name of the file, and then open that file for input. The remainder of the input data will come from thait file. You may assume that the file contains 1000 values, each with three digits after the decimal point corresponding to the weights of the cereal boxes Processing: Compute the statistics requested above. The standard deviation should be computed as follows 1. For each number in the cata set, subtract the average, and square the resut 2. Compute the average of these squared differences. 3. Take the square root of the resut Output: Display the statistics, labeled, and with the statistics formatted to 3 decimal places. Sample output: Please ester the nane of ehe data fite CrSS.txt Chocolate Prosted Sugar Bombs statistiess Average veight: 20.505 Nanber of boxes below 20 ounces1 The fine for this is: 1000000 Maxinun veight of al1 boxesI 21-103 Minimun velght of all boxes: 19-94 Your program should test for file open errors You can use pow(x, 2) to square x, and sqrt(x) to get the square root of x (these functions require the cmath header file to be included) You should have at least 4 separate loops in your program * Your program must compile and run, ottenstrou recenta
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
