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 IPT calculation (calculate a percentage of a figure)

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 01-04-2011, 12:00 PM PM User | #1 mynton New to the CF scene   Join Date: Jan 2011 Posts: 1 Thanks: 0 Thanked 0 Times in 0 Posts IPT calculation (calculate a percentage of a figure) Hi, I am fairly new to this so please bare with me. I have a php page that uses Javascript (I think) to calculate the percentage Insurance Premium Tax (IPT field) of a total. I have located where the calculation occurs and can see that it take the total of a predefined amount and divides it by 21 to give me the 5% IPT tax. IPT has risen in the UK today to 6% so I need to know what I need to change the 21 to to give me an accurate IPT calculation. Here's a snippet of the code. Can anyone help please? Is it 17.65? PHP Code: ``` //////////////////////////////////////////// // Motor Bike Calculations //////////////////////////////////////////// \$p = 3; \$q = 0;   while (\$p < 6){   \$base_array = mysql_fetch_row(\$result4);   // Motor Bikes   \$risk_code = 2;   \$ap = (0 + (\$p));           \$ipt_rate = \$ipt_main;   \$monthly_total = \$pricing_row[\$ap];   // Calculate IPT   \$ipt_percentage = \$monthly_total / 21;   \$monthly_ipt = \$ipt_percentage;     \$base_cost = \$base_array[0] + \$dealer_loading;   \$base_final = \$base_cost;      \$profit = \$monthly_total - \$base_cost - \$monthly_ipt;            \$monthly_total = number_format(\$monthly_total, 2, '.', '');             \$monthly_ipt = number_format(\$monthly_ipt, 2, '.', '');                 \$base_final = number_format(\$base_final, 2, '.', '');                     \$profit = number_format(\$profit, 2, '.', '');                        echo '
'; if (\$p == 3) { echo (''); } elseif (\$p == 4) { echo ('UK'); } elseif (\$p == 5) { echo ('UK & European'); } echo '               '.\$monthly_ipt.''.\$base_final.''.\$profit.'
';   \$q++; \$p++; }  ``` Last edited by mynton; 01-04-2011 at 12:05 PM..
 01-04-2011, 11:15 PM PM User | #2 Old Pedant Supreme Master coder!     Join Date: Feb 2009 Posts: 24,955 Thanks: 75 Thanked 4,308 Times in 4,275 Posts Nope. Not a lick of JavaScript in there. That's 100% PHP code. But you know, the language in use has nothing to do with this. It's just simple arithmetic. 105 / 21 is indeed 5. Simply because, of course, 105 / 5 is 21. What you need is to solve for x where 106 / x = 6. And simple algebra says x = 106 / 6 or 17.666666667 (that is 17 and 2/3). So, you almost had the right answer. Just a shade off. You might want to multiply by 6 and then divide by 106 to get as accurate an answer as possible. __________________ An optimist sees the glass as half full. A pessimist sees the glass as half empty. A realist drinks it no matter how much there is. Last edited by Old Pedant; 01-04-2011 at 11:20 PM..

 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 07:49 AM.