### Need help with Programming statistics

Not sure how to start on the homework assignment.
Assignment:
Write a C++ program that accepts 5 integers from a user and then calculates their arithmetic mean, geometric mean, harmonic mean, and standard deviation (all statistics must be stored in doubles). The program should then print and label the original 5 numbers and the four statistics. You will need to include the math library (#include <cmath>) to use pow() and sqrt().

Your program must implement the following equations:
Arithmetic Mean
Geometric Mean
Harmonic Mean
Standard Deviation

Any help would be greatly appreciated.
Thank you.
I'd start by writing out the 5 equations you need in pseudo-code:
 1234 AM = (a + b + c + d + e) / 5 GM = (abcde) ^ (1/5) HM = 1 / ((1/a + 1/b + 1/c + 1/d + 1/e) / 5) SD = sqrt(((a - AM)^2 + (b - AM)^2 + (c - AM)^2 + (d - AM)^2 + (e - AM)^2) / 5)

The rest should just be basic I/O.
Last edited on
 1234567891011121314151617 #include #include using namespace std; int main() { AM = (a+b+c+d+e)/ 5.0 GM = (abcde)^(1.0/5.0) HM = 1.0 / (1.0/a + 1.0/b + 1.0/c + 1.0/d + 1.0/e) / 5.0) SD = sqrt(((a-AM)^2.0 + (b - AM)^2.0 + (c - AM)^2.0 + (d - AM)^2.0 + (e - AM)^2.0) / 5.0) cout << << endl; return 0; }

I'm still stuck on what else to write out.

Thanks.
Last edited on
 12345678910111213141516171819202122232425262728 include include using namespace std; int main() { int a, b, c, d, e; cout << " Enter the first integer "; cin >> first integer; cout << " Enter the second integer "; cin >> second integer; cout << " Enter the third integer "; cin >> third integer; cout << " Enter the fourth integer "; cin >> fourth integer; cout << " Enter the fifth integer "; cin >> fifth integer; cin >> a >> b >> c >> d >> e; cout << } { arithMean = calc(a+b+c+d+e) / 5.0 return ArithMean; geoMean = pow(abcde)^(1/5) return geoMean; harmoMean = calc 1.0 / (1.0/a + 1.0/b + 1.0/c + 1.0/d + 1.0/e) / 5.0) return harmoMean; standdev = sqrt(((a - AM)^2.0 + (b - AM)^2.0 + (c - AM)^2.0 + (d - AM)^2.0 + (e - AM)^2.0) / 5.0

Still having troubles linking them together and am I missing anything important? How would I do a summation?

Thanks.
Topic archived. No new replies allowed.