JavaScript programme
<p>I am putting an interactive java script form whereas the the out put is getting confused with switch case. Kindly help me:  It is pipe weight calculation.</p>

<p>Pipe sizes: 100mm, 150 mm, 200 mm, 250mm up to 1000mm
For each pipe the pressure class varies: PN3, PN6 and PN9
For each pressure class the stiffness varies: SN124 and SN256</p>

<p>For given Pipes size, pressure class and stiffness class - the weight will be different.  To arrive the out put - I am using the switch case, which is very lengthy and time consuming. Any body can help me in solving the java script so that same will be put in the HTML file. </p>

<p>This is the code I have, but I think there must be a better way to do it.</p>

<p>What's a better way?</p>

<pre><code>&lt;SCRIPT LANGUAGE="JavaScript"&gt;
function CalculateSum(Atext, Btext, Ctext,form)
{
var A = parseFloat(Atext);
var B = parseFloat(Btext);
var C = parseFloat(Ctext);

switch (true){
case (A == 100 &amp;&amp; B == 3  &amp;&amp; C == 124): K =21.4; L=102; M =55; break ;
case (A == 100 &amp;&amp; B == 3  &amp;&amp; C == 256): K =21.9; L=125; M=49;  break ;
case (A == 100 &amp;&amp; B == 3  &amp;&amp; C == 512): K =22.2; L=133; M=45;  break ;
case (A == 100 &amp;&amp; B == 6  &amp;&amp; C == 124): K =42.9; L=139; M=41;  break ;
case (A == 100 &amp;&amp; B == 6  &amp;&amp; C == 256): K =42.78;L=141; M=39;  break ;
case (A == 100 &amp;&amp; B == 6  &amp;&amp; C == 512): K =43.01;L=144; M=37;  break ;
case (A == 100 &amp;&amp; B == 9  &amp;&amp; C == 124): K =54.84;L=148; M=34;  break ;
case (A == 100 &amp;&amp; B == 9  &amp;&amp; C == 256): K =55.02;L=152; M=31;  break ;
case (A == 100 &amp;&amp; B == 9  &amp;&amp; C == 512): K =56.90;L=157; M=29;  break ;
case (A == 150 &amp;&amp; B == 3  &amp;&amp; C == 124): K =39.4; L=164; M=25;  break ;
....
......
.......
break ;
}
    form.Ans1.value = K  + "   Kg/Rmt"; 
    form.Ans1.value = L  + "   Rmt";
    form.Ans1.value = M  + "   Nos";

}
&lt;/SCRIPT&gt;
</code></pre>
