...

View Full Version : Formulas not accurate?



eric678
08-02-2006, 02:56 PM
Hello,
First off, I wanted to say thank you to those who have helped me so far. It is amazing being new and struggling with a script and then having one of you turn around and find the problem in a few minutes. This forum is a great learning tool for me.
Well, now I am having trouble with my formulas for my salmon calculator. When I select seafoodgrill from the pull down menu and then enter 10.99 per lb, 85 % yield, and 25.50 price I get a 23% food cost. That is not correct. The correct answer should be around 24.6%. How have I set up the formula wrong. Any help on this would be appreciated.

Eric


<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>FISH CALCULATOR</title>
<script language="javascript">

function reset(){
var frm=document.calc;
frm.val1.value="";
frm.val2.value="";
frm.val3.value="";
frm.answer.value="";
}


function initialise(){
}

function cost(){
var frm=document.calc;
var x =parseInt(frm.val1.value)||0;
var y =parseInt(frm.val2.value)||0;
var z =parseInt(frm.val3.value)||0;
if (frm.concept.value=='newportbay')
frm.answer.value=(((x/3.200)*(100/y)+1.894)/z)*100
if (frm.concept.value=='stanfords')
frm.answer.value=(((x/2.462)*(100/y)+2.059)/z)*100
if (frm.concept.value=='chophouse')
frm.answer.value=(((x/2.462)*(100/y)+1.593)/z)*100
if (frm.concept.value=='citygrill')
frm.answer.value=(((x/2.462)*(100/y)+2.140)/z)*100
if (frm.concept.value=='manzana')
frm.answer.value=(((x/2.462)*(100/y)+1.380)/z)*100
if (frm.concept.value=='henrys')
frm.answer.value=(((x/2.462)*(100/y)+1.530)/z)*100
if (frm.concept.value=='seafoodgrill')
frm.answer.value=((((x/2.462)*(100/y))+1.030)/z)*100
}

</script>

</head>
<body style="text-align: center; background-image: url(bgfish3gif_100.gif);">
<span style="font-family: Tahoma"><span style="font-family: Baskerville Old Face"><strong>
<span style="font-size: 36pt; text-decoration: underline">FISH CALCULATOR</span></strong><br />
<br />
<br />
<strong>
KING SALMON PLATE COST CALCULATOR</strong></span><br />
</span>
<br />
<form name="calc" >
<table border="2">
<tr>
<td align="center" style="width: 100px; height: 30px;" valign="middle">
Select<br />
<select name="concept" size=1>
<option selected value="">CONCEPT
<option value="newportbay">newportbay
<option value="stanfords">stanfords
<option value="chophouse">chophouse
<option value="citygrill">citygrill
<option value="manzana">manzana
<option value="henrys">henrys
<option value="seafoodgrill">seafoodgrill
</select>
</td>
<td align="center" style="width: 100px; height: 30px;" valign="middle">
Per LB Price<br />
<input type="text" name="val1" size=10 id="Text1">
</td>
<td align="center" style="width: 100px; height: 30px;" valign="middle">
Yield<br />
<input type="text" name="val2" size=10 id="Text2">
</td>
<td align="center" style="width: 100px; height: 30px;" valign="middle">
Menu Price<br />
<input type="text" name="val3" size=10 id="Text3">
</td>
<td align="center" style="width: 100px; height: 30px" valign="middle">
=
Plate Cost<br />
<input type="text" name="answer" size=10 id="Text4" contenteditable="false">
</td>
</tr>
</table>

<br />
<input type="button" value="cost" size=10 onclick="cost()">
<input type="reset" value="reset" size=10 onclick="reset()">
<br />
<br />
</form>
</body>
</html>

vwphillips
08-02-2006, 03:33 PM
function cost(){
var frm=document.calc;
var x =parseFloat(frm.val1.value)||0;// Note parseFloat
var y =parseFloat(frm.val2.value)||0;
var z =parseFloat(frm.val3.value)||0;
if (frm.concept.value=='newportbay')
frm.answer.value=(((x/3.200)*(100/y)+1.894)/z)*100
if (frm.concept.value=='stanfords')
frm.answer.value=(((x/2.462)*(100/y)+2.059)/z)*100
if (frm.concept.value=='chophouse')
frm.answer.value=(((x/2.462)*(100/y)+1.593)/z)*100
if (frm.concept.value=='citygrill')
frm.answer.value=(((x/2.462)*(100/y)+2.140)/z)*100
if (frm.concept.value=='manzana')
frm.answer.value=(((x/2.462)*(100/y)+1.380)/z)*100
if (frm.concept.value=='henrys')
frm.answer.value=(((x/2.462)*(100/y)+1.530)/z)*100
if (frm.concept.value=='seafoodgrill')
frm.answer.value=((((x/2.462)*(100/y))+1.030)/z)*100
}

vwphillips
08-02-2006, 03:40 PM
better


function cost(){
var frm=document.calc;
var x =parseFloat(frm.val1.value)||0;
var y =parseFloat(frm.val2.value)||0;
var z =parseFloat(frm.val3.value)||0;
var answ=0;
if (frm.concept.value=='newportbay')
answ=(((x/3.200)*(100/y)+1.894)/z)*100;
if (frm.concept.value=='stanfords')
answ=(((x/2.462)*(100/y)+2.059)/z)*100;
if (frm.concept.value=='chophouse')
answ=(((x/2.462)*(100/y)+1.593)/z)*100;
if (frm.concept.value=='citygrill')
answ=(((x/2.462)*(100/y)+2.140)/z)*100;
if (frm.concept.value=='manzana')
answ=(((x/2.462)*(100/y)+1.380)/z)*100;
if (frm.concept.value=='henrys')
answ=(((x/2.462)*(100/y)+1.530)/z)*100;
if (frm.concept.value=='seafoodgrill')
answ=((((x/2.462)*(100/y))+1.030)/z)*100;
frm.answer.value=answ.toFixed(2);

}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum