Hey yall. Trying to teach myself C++ using the book "Programming and Problem Solving With C++" (5th ed.) by: Nell Dale and Chip Weems... and it's no cake walk. I have a new found respect for programmers and programming in general. Anyway, if any of yall can help me figure out the coding for this, I'd be in your debt.

p. 180
3.) Write a C++ program that computes and outputs the mean and standard deviation of a set of four integer values that are input by the user. The mean is the sum of the four values divided by 4, and the formula for the standard deviation is:

n
s= ∑ (x - x)^2
i=1 n=1


(The 'E' stands for the Sigma symbol (summation). For the 1st 'x', there should be an 'i' as a subscript. For the 2nd 'x', it is supposed to be an x-overbar: The overline is used to indicate a sample mean. The entire equation (after s=) should be housed under a big square root symbol. Treat the division sign(s) as a simple division line. The 'n' should be directly over the 'E' and the i=1 should be directly under the 'E' (Sigma).

Thanx Yall,
-Brooks

Recommended Answers

All 7 Replies

> I have a new found respect for programmers and programming in general.
LOL - and you want someone to do your homework after that little speech.

No, stop, my sides are splitting, I can't stop LAUGHING!!!!!!!

Thanks kid, that's the best funny I've seen in a long while.

Good luck with the homework, feel free to come back when you've made an actual EFFORT.

Or, search the forum for "calculator" -- there's a recurring homework assignment on that topic, it will get you most of the way to computing the mean, and from there you can take a stab at the standard deviation.

Member Avatar for iamthwee

C'mon... I mean how many variations of this BS do we have to see OVER and OVER again.

If it's not the 'Hey can any solve this impossible problem?' To the 'Wow I really respect all programmers out there...'

I mean do you (the OP) believe this crap that you have just written??

Let's see, do you want to fail in life OVER and OVER again? The decision for recovery from this mindless knuckle-nut existence can take place today. What are you going to do?

Sum: for (i = 1; i <= n; i++)
{
// compute value for i
// add value to total
}

I have simple algorithm for you ;)

  1. Learn to think
  2. Learn basic math
  3. Learn software design
  4. Learn C++
  5. Learn to use IDE
  6. Learn to debug

Points 4, 5 and 6 need actually some parallel processing :)

Unless you are using somebody elses program you can't do standard deviations by just turning on the computer. Someone needs to write a program to do it. In this case it's you. One of the useful tools in writing programs is to recognize patterns. Another is the ability to break a problem that involves multiple steps into each smaller step. The only tricky thing here is knowing that you don't have to do the squaring and the square rooting yourself as there is a standardized funcion in C++ called pow() that will do that for you. If your're not familiar with pow() by now, here's your chance to learn. Look it up in your favorite refernce and read about it before you even start to write the program. Then write the program in steps, each step building on the former.

1) write a program to determine the sum of 4 numbers
2) write a program to determine the mean of 4 numbers
3) write a program to generate the difference between the mean and each of the 4 numbers used in the program
4) write a program to square the differences generated in step 3.
5) write a program to sum the squared differences.
6) write a program to get the square root of the sums of the squared differences.
7) Adjust any of the above if I made a mistake in outlining the steps.

Between each step be sure the code compiles and runs as expected. That is, use pencil and paper to do the calculations by hand to be sure you are gettng the output you want at each step along the way. If you have questions about any step, then post specific questions and relevant code. If you aren't willing to any of the above steps, then it's unlikely anyone here will do it for you.

commented: Good "beginning is good place to start" advice +13
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.