@ Chervil && @ AbstractionAnon
Thank you so much I Finally got it to work! You two were great help! I have learned more this week then any other! I can not think you two enough! Here is my finished code just to show you that every thing worked:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
// main.cpp
// Program 6
// Created by William Blake Harp on 7/10/14.
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
int exam_scores[] = {55, 74, 93, 84, 64, 72, 69, 78, 87, 84, 72, 33, 83, 68, 62, 51, 88, 90};
int const SIZE = sizeof(exam_scores)/sizeof(exam_scores[0]);
double sum_of_exam_scores;
double average;
int count;
int highest_exam_score;
int lowest_exam_store;
double standard_deviation;
int deviation = 0;
cout << "The exam scores are listed below." << endl
<< "---------------------------------" << endl;
// Printing out the exam scores in rows of four.
for (count = 0; count < SIZE; count++)
{
if ((count % 4) == 0)
cout << endl;
cout << exam_scores[count] << ", ";
}
cout << endl << endl;
// Finding the average.
for (count = 0; count != SIZE; count++)
{
sum_of_exam_scores += exam_scores[count];
}
average = sum_of_exam_scores / SIZE;
cout << setprecision(2) << fixed;
cout << "The average of the exam scores are: " << average << endl;
highest_exam_score = exam_scores[0];
// Finding the highest exam score.
for (count = 0; count != SIZE; count++)
{
if (exam_scores[count] > highest_exam_score)
{
highest_exam_score = exam_scores[count];
}
}
cout << "The highest exam score is: " << highest_exam_score << endl;
lowest_exam_store = exam_scores[0];
// Finding the lowest exam score.
for (count = 1; count != SIZE; count++)
{
if (exam_scores[count] < lowest_exam_store)
{
lowest_exam_store = exam_scores[count];
}
}
cout << "The lowest exam score is: " << lowest_exam_store << endl;
// finding the deviation of each score.
cout << "The deviation of each score is listed below:" << endl << endl;
cout << "Score: ----- Deviation:";
for (count = 0; count < SIZE; count++)
{
if (count != SIZE)
deviation = exam_scores[count] - average;
cout << endl;
cout << setw(3) << fixed;
cout << exam_scores[count] << " | " << deviation << endl;
cout << " --------------------";
}
cout << endl << endl;
// Finding the standard deviation.
standard_deviation = sqrt(pow(exam_scores[count] - average, 2.0) / SIZE);
cout << "The standard deviation is: " << standard_deviation << endl << endl;
// Finding how meany scores are with in one standard deviation: 55.5 OR 89.72
cout << "The exam scores that are with in one standard devation are:" << endl << endl;
for (count = 0; count < SIZE; count++)
{
if (exam_scores[count] >= 55.5 && exam_scores[count] <= 89.72)
{
cout << exam_scores[count] << ", ";
}
}
return 0;
}//End Code!
|
and here is the out put:
The exam scores are listed below.
---------------------------------
55, 74, 93, 84,
64, 72, 69, 78,
87, 84, 72, 33,
83, 68, 62, 51,
88, 90,
The average of the exam scores are: 72.61
The highest exam score is: 93
The lowest exam score is: 33
The deviation of each score is listed below:
Score: ----- Deviation:
55 | -17
--------------------
74 | 1
--------------------
93 | 20
--------------------
84 | 11
--------------------
64 | -8
--------------------
72 | 0
--------------------
69 | -3
--------------------
78 | 5
--------------------
87 | 14
--------------------
84 | 11
--------------------
72 | 0
--------------------
33 | -39
--------------------
83 | 10
--------------------
68 | -4
--------------------
62 | -10
--------------------
51 | -21
--------------------
88 | 15
--------------------
90 | 17
--------------------
The standard deviation is: 17.11
The exam scores that are with in one standard devation are:
74, 84, 64, 72, 69, 78, 87, 84, 72, 83, 68, 62, 88,