#include #include using namespace std; // The final grades for a Physics exam taken by a large group of // students have a mean of 70 and a standard deviation of 10. If we // can approximate the distribution of these grades by a normal // distribution, what percentage of the students: // 1. Scored higher than 80 (i.e., have a grade > 80 )? // 2. Passed the test (i.e., have a grade >= 60)? // 3. Failed the test (i.e., have a grade < 60 )? // Expected Output // 15.87 // 84.13 // 15.87 int main() { int mean = 70; // mu int stddev = 10; // sigma // Probability P(X <= x) auto normalCDF = [](double x, double mean, double stddev) { double val = (x - mean)/(stddev * sqrt(2)); return 0.5 * (1 + (erf(val))); }; double answer_1 = (1 - normalCDF(80, mean, stddev)) * 100; double answer_2 = (1 - normalCDF(60, mean, stddev)) * 100; double answer_3 = normalCDF(60, mean, stddev) * 100; cout << fixed << setprecision(2) << answer_1 << endl; cout << fixed << setprecision(2) << answer_2 << endl; cout << fixed << setprecision(2) << answer_3 << endl; }