Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com > ASP Averaging Numbers (rating system)

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 08-23-2005, 12:52 AM PM User | #1 isaaclloyd New Coder   Join Date: Dec 2002 Location: Washington State Posts: 98 Thanks: 0 Thanked 0 Times in 0 Posts Averaging Numbers (rating system) Here is the script I am working on: Code: ```<% n1 = 9 n2 = 0 n3 = 0 n4 = 0 n5 = 0 random_total= n1 + n2 + n3 + n4 + n5 total_score = random_total/5 %>
<% for count = 1 to round(total_score) %> • <% next %> <% for counter = 1 to round((5-total_score)) %> • <% next %>
<%= round(total_score) & " out of 5" %>``` With the 5 different ratings above being 9,0,0,0,0 the average rating should be 1 shouldn't it? Maybe my math is all wrong but this average stuff doesn't seem right. If 5 visitors vote 1 out of 5 stars, and 5 visitor votes 5 out of 5 stars, the average should be like 3, with the script above I get 2.... Anyways, if anyone can see something I am doing wrong I would appreciate the help. Thanks. ~Isaac~ __________________ ~ Isaac Lloyd ~ Website Design & Development http://www.IsaacLloyd.com
 08-23-2005, 01:36 AM PM User | #2 CrzySdrs Regular Coder   Join Date: Jun 2003 Location: Silicon Forest Posts: 155 Thanks: 0 Thanked 5 Times in 5 Posts If I am reading what you are trying to do correctly... you intend for n1 to mean the number of people voting 1, n2 number of people voting 2, etc. Which means that to get the average score, you would need to... Code: ```n1 = 9 n2 = 0 n3 = 0 n4 = 0 n5 = 0 average_score= ( (n1 * 1) + (n2 * 2) + (n3 * 3) + (n4 * 4) + (n5 * 5) ) / (n1 + n2 + n3 + n4 + n5)``` Assuming thats what you were trying to accomplish... __________________ Whats the point of a signature?

 Bookmarks

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 01:22 AM.