- Readme First! - Read and follow the rules, otherwise your posts will be closed
There are currently, 53 guest(s) and 0 member(s) that are online. You are Anonymous user. You can register for free by clicking here
Nuke Cops :: View topic - I need help with mathmatical issue [ ]
Author
Message
White_Devil
Nuke Cadet
Joined: Jan 08, 2006
Posts: 5
Posted:
Fri Mar 03, 2006 6:09 am
It not really a coding problem but a mathmatical issue.
I am writing a hot or not type script for php-nuke. Check out hotornot.com to see what i am going to ask.
When a user clicks a vote number 1-10 .. It will then take it and compare to the total votes and get an advrage. oviously 1-10.
My questions are...
How do i get the advarage?
Do i need to record all votes to make it work?
jakec06
Sergeant
Joined: Jan 30, 2006
Posts: 75
Location: Surrey, UK
Posted:
Fri Mar 03, 2006 10:53 am
To get the average all you need to do is add the votes together and divide by the number of votes.
For example:
Person 1 votes = 7
Person 2 votes = 5
Person 3 votes = 6
Add them together: 7+5+6 = 18
Divide that by the total number of votes: 18/3=6 (average)
You wouldn't need to record all the votes just keep adding the new vote to the sum of the previous votes and divide by the total number of votes.
Jakec
White_Devil
Nuke Cadet
Joined: Jan 08, 2006
Posts: 5
Posted:
Fri Mar 03, 2006 12:51 pm
Thank you that helped out alot. Made me think of how I should do it exactly. Your help was much appreciated. Thanks again.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum