5 Replies - 503 Views - Last Post: 28 April 2010 - 05:27 PM Rate Topic: -----

#1 sauske  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 3
  • Joined: 28-April 10

Hanging at home trying to make a code for fun

Posted 28 April 2010 - 05:19 PM

I need help with a standard deviation program. im using visual studion 2008. I have been having problems making it work properly. I need it to compute the mean for the data set 1st. then computer the deviation by subtracting the mean from each value 2nd. square each individual deviation 3rd. add up te square deviations 4th. divide by one less than the sample size 5th. take the square root 6th. [20, 30, 10, 50, 60]

i need to make into array and calculate the SD (using functions) Sum() Avg() calc (subtracting the square root) and calcualte (using loops) 1. Avg 2. Max 3. Min i can make this a serperate program but i cant get it to work can anyone help me out i need it done today. Thank you.

#include <iostream
#include <string>
#include <cmath>

using namespace std;


int main()
{

	bool	more	= true;
    int		count	= 0;
    double	sum		= 0;
    
	float	num		= 0.0;
	double	avg		= 0;
 	double	s_dev	= 0;
 
    
	cout << " Enter a value: (CTRL-D to quit): ";
    
	cin >> num;
    
	while (true)
    
	{
    
		++count;
        cout << count << endl;
        
        sum += num;
        
        cout << " Enter a value: (CTRL-D to quit): ";
        cin >> num;
 
		if  (cin.eof())
		{
			break;
		}
        
	}


    
   
	avg = sum / count;

	s_dev = sqrt((( pow(sum,2.0)) -(( 1.0/count) * (pow(sum,2.0)))) / (count - 1.0)
		);
    
	cout << endl << endl;
    
	cout << " There are " << count << " values. " << endl;
    
	cout << " The average is:  " << avg << endl;
    
	cout << " The standard deviation is:  " << s_dev << endl;

 
	return 0;

}


Reason need it done today is cause a friend is leaving to China soon and needs it for statistics? idk i told him id make him something to use and no luck lol

This post has been edited by JackOfAllTrades: 28 April 2010 - 05:22 PM
Reason for edit:: Added code tags.


Is This A Good Question/Topic? 0
  • +

Replies To: Hanging at home trying to make a code for fun

#2 jjl  Icon User is online

  • Engineer
  • member icon

Reputation: 1086
  • View blog
  • Posts: 4,563
  • Joined: 09-June 09

Re: Hanging at home trying to make a code for fun

Posted 28 April 2010 - 05:22 PM

Quote

Reason need it done today is cause a friend is leaving to China soon and needs it for statistics? idk i told him id make him something to use and no luck lol

that is the biggest load of crap i have ever heard. Do you know what a network is? you can also email to him if he existed. You dont have to be scared to say that you need help on your homework

Can you fix your code by pasting is in the appropriate code tags?
:code:
Was This Post Helpful? 1
  • +
  • -

#3 sauske  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 3
  • Joined: 28-April 10

Re: Hanging at home trying to make a code for fun

Posted 28 April 2010 - 05:24 PM

I need it done today cause friend is leaving to chine soon and needs it for statistics? lol anyway i told him id make him something to use and i havent goten it done lol thnak you.
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6078
  • View blog
  • Posts: 23,546
  • Joined: 23-August 08

Re: Hanging at home trying to make a code for fun

Posted 28 April 2010 - 05:24 PM

Quote

Hanging at home trying to make a code for fun


LOL. Uh-huh. And you need it right away...for a friend leaving for China. Wow.

:bs:
Was This Post Helpful? 0
  • +
  • -

#5 jjl  Icon User is online

  • Engineer
  • member icon

Reputation: 1086
  • View blog
  • Posts: 4,563
  • Joined: 09-June 09

Re: Hanging at home trying to make a code for fun

Posted 28 April 2010 - 05:26 PM

im not gonna help you until you tell me the truth

This post has been edited by ImaSexy: 28 April 2010 - 05:27 PM

Was This Post Helpful? 0
  • +
  • -

#6 sauske  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 3
  • Joined: 28-April 10

Re: Hanging at home trying to make a code for fun

Posted 28 April 2010 - 05:27 PM

View PostImaSexy, on 28 April 2010 - 04:22 PM, said:

Quote

Reason need it done today is cause a friend is leaving to China soon and needs it for statistics? idk i told him id make him something to use and no luck lol

that is the biggest load of crap i have ever heard. Do you know what a network is? you can also email to him if he existed. You dont have to be scared to say that you need help on your homework

Can you fix your code by pasting is in the appropriate code tags?
:code:


well its not homework but i do need help
Was This Post Helpful? -1
  • +
  • -

Page 1 of 1