Question
Problem: You will write a program to compute some statistics about boxes of a popular breakfast cereal called Chocolate Frosted Sugar Bombs manufactured by the
Problem: 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 companys factory to fill 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 CFSB.txt on the class website gives the weight (in ounces) of the last 1,000 boxes of Chocolate Frosted Sugar Bombs produced in the factory. For every box in this sample that weighs less than the advertised 20 ounces, General Junkfoods 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 that 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 data set, subtract the average, and square the result. 2. Compute the average of these squared differences. 3. Take the square root of the result. Output: Display the statistics, labeled, and with the statistics formatted to 3 decimal places.
Sample output:
Additional Requirements: 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, otherwise you will receive a 0. See the Style Guidelines document on the course website.
The grader will deduct points if your program violates the style guidelines. Make sure it is indented neatly. Please keep it as simple as possible for C++.
CFSB.txt
20.440 20.244 20.549 20.755 20.740 20.847 20.063 20.453 20.719 20.283 20.362 20.162 20.131 20.304 20.345 20.076 20.386 20.419 20.527 20.427 20.435 20.426 20.769 20.483 20.463 20.397 20.894 20.673 20.975 20.369 20.832 20.178 20.608 20.680 20.884 20.483 20.395 20.635 20.424 20.652 20.211 20.331 20.196 20.427 20.494 20.506 20.435 20.939 20.152 20.353 19.984 20.790 20.244 20.369 20.652 20.593 20.675 20.619 20.226 20.277 20.639 20.565 20.312 20.452 20.526 20.612 20.528 20.318 20.877 20.597 20.514 20.666 20.672 20.373 20.315 20.722 20.260 20.188 20.642 20.628 20.941 20.789 20.761 20.523 20.500 20.591 20.495 20.289 20.145 20.666 20.589 20.624 20.543 20.295 20.748 20.438 20.332 20.336 20.414 20.409 20.395 20.670 20.603 20.378 20.761 20.148 20.610 20.477 20.508 20.369 20.390 20.670 20.661 20.591 20.638 20.826 20.561 20.618 20.871 20.433 20.708 20.529 20.728 20.470 20.344 20.715 20.384 20.607 20.609 20.437 20.412 20.227 20.899 20.387 20.517 20.453 21.067 20.750 20.676 20.766 20.538 20.608 20.450 20.256 20.753 20.442 20.239 20.653 20.657 20.586 20.581 20.370 20.645 20.605 20.715 19.946 20.593 20.793 20.155 20.509 20.771 20.838 20.548 20.529 20.871 20.491 20.369 20.681 20.498 20.708 20.587 20.791 20.476 20.308 20.192 19.987 20.521 20.560 20.496 20.540 20.552 20.795 20.517 20.277 20.222 20.538 20.690 20.198 20.378 20.605 20.457 20.431 20.467 20.412 20.339 20.629 20.512 20.753 20.552 20.511 20.545 20.543 20.499 20.255 20.547 20.530 20.650 20.353 20.623 20.544 20.523 20.674 20.861 20.238 20.253 20.612 20.738 20.324 20.071 20.320 20.540 20.586 20.303 20.328 20.592 20.524 20.392 20.520 20.312 20.321 20.709 20.825 20.366 20.466 20.523 20.869 20.619 20.831 20.535 20.812 20.371 20.307 20.739 20.684 20.154 20.754 20.460 20.273 20.124 20.335 20.595 20.684 20.486 20.489 20.543 20.430 20.686 20.401 20.969 20.649 20.622 20.304 20.674 20.789 20.354 20.440 20.232 20.771 20.709 20.537 20.062 20.601 20.605 20.743 20.308 20.741 20.388 20.353 20.155 20.775 20.307 20.809 20.267 20.418 20.238 20.818 20.506 20.566 20.695 20.890 20.488 20.294 20.386 20.670 20.674 20.602 20.203 20.221 20.471 20.374 20.374 20.676 20.332 20.477 20.454 20.804 20.237 20.313 20.467 20.288 20.213 20.067 20.616 20.432 20.583 20.090 20.734 20.110 20.397 20.305 20.480 20.527 20.847 20.399 20.341 20.351 20.617 20.757 20.213 20.694 20.818 20.367 20.517 20.334 20.639 20.548 20.509 20.294 20.440 20.645 20.498 20.700 20.297 20.652 20.748 20.266 20.579 20.144 20.516 20.701 20.707 20.521 20.348 20.616 20.593 20.646 20.310 20.619 20.822 20.547 20.423 20.550 20.864 20.020 20.503 20.475 20.698 20.747 20.827 20.136 20.661 20.573 20.648 20.597 20.473 20.832 20.591 20.494 20.496 20.490 20.163 20.589 20.539 20.630 20.466 20.665 20.764 20.880 20.238 20.624 20.457 20.352 20.648 20.966 20.770 20.536 20.405 20.452 20.280 20.515 20.448 20.628 20.245 20.604 20.695 20.327 20.574 20.606 20.695 20.455 20.547 20.416 20.602 20.815 20.468 20.295 20.316 20.646 20.819 20.374 20.334 20.705 20.545 20.590 21.020 20.384 20.343 20.742 20.439 20.217 20.724 20.242 20.420 20.212 20.280 20.621 20.524 20.150 20.907 20.548 20.785 20.495 20.452 20.506 20.130 20.362 20.777 20.534 20.412 20.379 20.271 20.750 20.994 20.683 20.480 20.328 20.483 20.449 20.421 20.674 20.443 20.569 20.659 20.548 20.174 20.505 20.630 20.468 20.170 20.180 20.337 20.552 20.378 20.913 20.457 20.673 20.748 20.408 20.131 20.320 20.520 20.554 20.679 20.085 20.364 20.531 20.528 20.485 20.452 20.794 20.668 20.234 20.405 20.448 20.313 20.460 20.530 20.308 20.668 20.465 20.641 20.349 20.562 20.248 20.957 20.666 20.275 20.798 20.446 20.216 20.414 20.555 20.358 20.617 20.453 20.606 20.115 20.278 20.797 20.541 20.679 20.255 20.246 20.450 20.463 20.703 20.703 20.442 20.601 20.690 20.346 20.352 20.440 20.601 20.156 20.740 20.885 20.503 20.242 20.504 20.796 20.533 20.753 20.711 20.574 20.348 20.412 20.768 20.591 20.641 20.311 20.080 20.490 20.700 20.681 20.401 20.365 20.557 20.286 20.607 20.181 20.791 20.824 20.368 20.756 20.640 20.685 20.281 20.753 20.413 20.750 20.181 20.320 21.103 20.415 20.417 20.634 20.438 20.152 20.510 20.680 20.679 20.449 20.590 20.862 20.589 20.517 20.391 20.557 20.496 20.818 21.081 20.133 20.528 20.836 20.693 20.539 20.731 20.703 20.479 20.344 20.300 20.269 19.997 20.260 20.634 20.661 20.741 20.412 20.248 20.125 20.402 20.426 20.694 20.371 20.705 20.560 20.679 20.729 20.624 20.556 20.465 20.581 20.392 20.665 20.480 20.361 20.331 20.855 20.581 20.514 20.708 20.312 20.511 20.463 20.602 20.861 20.417 20.799 20.621 20.821 20.905 20.682 20.898 20.489 20.503 20.805 20.365 20.534 20.278 20.496 20.781 20.565 20.516 20.345 20.116 20.388 20.170 20.713 20.498 20.735 20.725 20.678 20.622 20.656 20.558 20.485 20.432 20.368 20.476 20.873 20.500 20.803 20.355 20.847 20.250 20.580 20.593 20.284 21.005 20.618 20.293 20.208 20.170 20.411 20.180 20.246 20.142 20.359 20.440 20.713 20.647 20.470 20.469 20.319 20.763 20.703 20.388 20.837 20.307 20.661 20.791 20.569 20.362 20.459 20.641 20.130 20.331 20.569 20.424 20.261 20.550 20.651 20.158 20.413 20.348 20.581 20.458 20.398 20.535 20.307 20.313 20.420 20.884 20.133 20.472 20.574 20.554 20.812 20.163 20.557 20.295 20.579 20.640 20.329 20.457 20.394 20.244 20.579 20.585 20.473 20.597 20.570 20.965 20.327 20.575 20.076 20.474 20.697 20.325 20.430 20.382 20.427 20.669 20.475 20.863 20.412 20.267 20.628 20.480 20.467 20.177 20.336 20.386 20.342 20.237 20.476 20.719 20.368 20.479 20.485 20.678 20.451 21.000 20.023 20.500 20.355 20.475 20.764 20.572 20.438 20.249 20.416 20.345 20.741 20.390 20.415 20.507 20.385 20.721 20.518 20.500 20.484 20.273 20.516 20.465 20.266 20.361 20.624 20.710 20.638 20.599 20.301 20.721 20.241 20.633 20.204 20.724 20.796 20.552 20.676 20.561 20.202 20.159 20.686 20.718 20.554 20.412 20.325 20.389 20.269 20.348 20.572 20.308 20.870 20.631 20.456 20.430 20.395 20.588 20.751 20.176 20.157 20.400 20.463 20.823 20.451 20.537 20.323 20.358 20.242 20.760 20.536 20.258 20.894 20.171 20.828 20.211 20.298 20.372 20.360 20.726 20.434 20.758 20.321 20.404 20.572 20.133 20.609 20.643 20.853 20.987 20.415 20.518 20.289 20.493 20.062 20.229 20.488 20.369 20.373 20.303 20.414 20.679 20.185 20.637 20.476 20.406 20.434 20.280 20.831 20.220 20.632 20.631 20.681 20.642 20.695 20.327 20.881 20.657 20.396 20.342 20.550 20.938 20.884 20.657 20.726 20.170 20.600 20.350 20.637 20.625 20.620 20.549 20.074 20.476 20.314 20.219 20.274 20.336 20.381 20.622 20.325 20.472 20.933 20.393 20.521 20.683 20.660 20.481 20.353 20.468 20.260 20.341 20.920 20.542 20.374 20.595 20.674 20.490 20.372 20.337 20.835 20.249 20.519 20.763 20.398 20.543 20.717 20.519 20.783 20.347 20.443 20.818 20.711 20.584 20.383 20.690 20.760 20.366 20.649 20.325 20.485 20.237 20.243 20.299 20.307 20.725 20.328 20.513 20.410 20.776 20.527 20.654 20.210 20.560 20.327 20.714 20.283 20.573 20.216 20.490 20.098 20.127 20.837 20.383 20.606 20.607 20.899 20.522 20.520 20.443 20.158 20.707 20.510 20.506 20.356 20.423 20.495 20.236 20.384 20.062 20.539 20.296 20.469 20.551 20.447 20.597 20.615 20.567
Please enter the name of the data file: CFSB.txt Chocolate Frosted Sugar Bombs statistics: Average weight: 20.505 Standard Deviation: 0.204 Number of boxes below 20 ounces:4 The fine for this is: $1000000 Maximum weight of all boxes: 21.103 Minimum weight of all boxes: 19.946
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started