I was lately helping my uncle and were selling computer hardware and parts to people, so then I was tired of calculating with a calculator so I scripted something; it probably is not a full program as it is not an executable file, but I used Javascript and Xhtml 1.0 to code it. Anyone who wishes to use it may and you can also edit it to your liking. I hope I did an alright job. I have also validated it. I hope its useful.
PLEASE NOTE: The sales tax part is the New York Sales Tax, therefore, you will have to change that depending on where you live, you can also edited so that you can add the sales tax yourself. If you want, I can do further editing to it. You probably need JavaScript to use this, as well.
I have made a new version of it, please check it out and I have revised the V0 adding the stars, so you know those are the ones you are suppose to put information on. On the second one, I made it so you can try a different sales tax, though default is 8.375%. Please feedback on what you think. Thank you. If there are any errors or incorrect formulas, please tell me to fix or fix for me and tell me. Thank you. I hope V1 is much more useful.
Profit Calculator V0 REV0.1
Profit Calculator V1 REV0.
PLEASE NOTE: The sales tax part is the New York Sales Tax, therefore, you will have to change that depending on where you live, you can also edited so that you can add the sales tax yourself. If you want, I can do further editing to it. You probably need JavaScript to use this, as well.
I have made a new version of it, please check it out and I have revised the V0 adding the stars, so you know those are the ones you are suppose to put information on. On the second one, I made it so you can try a different sales tax, though default is 8.375%. Please feedback on what you think. Thank you. If there are any errors or incorrect formulas, please tell me to fix or fix for me and tell me. Thank you. I hope V1 is much more useful.
Profit Calculator V0 REV0.1
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- This scripting was scripted by ninjinsamax3. This is opened sourced, so please edited as you wish, but please give some credit. Thank you. -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy for Linux (vers 1 September 2005), see www.w3.org" />
<title>Profit Calculator V0 REV0.1</title>
<style type="text/css">
/*<![CDATA[*/
span {font-weight:bold;}
img {border:0px;}
/*]]>*/
</style>
</head>
<body>
<script type="text/javascript">
//<![CDATA[
function calculate()
{
var stateTax = 0.08375;
var shPrice = Number(document.form.shippingPrice.value);
var sPrice = Number(document.form.salesPrice.value);
var pWanted = Number(document.form.profitWanted.value) / 100;
var priceWithProfitWanted = (sPrice * pWanted) + sPrice;
var priceWithStateTax = (priceWithProfitWanted * stateTax) + priceWithProfitWanted;
var fPrice = priceWithStateTax + shPrice;
var pMade = fPrice - sPrice -shPrice;
document.form.finalPrice.value = fPrice.toFixed(2);
document.form.roundedPrice.value = fPrice.toFixed(0);
document.form.profitMade.value = pMade.toFixed(2);
document.form.roundedProfit.value = pMade.toFixed(0);
}
function formReset()
{
document.getElementById("form").reset()
}
//]]>
</script>
<table>
<tr>
<td>
<form name="form" id="form" action=""><p><span>*Sales Price: $</span><input type="text" name="salesPrice" value="" size="5" /><br />
<span>*Profit Wanted: </span><input type="text" name="profitWanted" value="" size="5" /><span>%</span><br />
<span>*Shipping Price: $</span><input type="text" name="shippingPrice" value="" size="5" /><br />
<span>Final Price: $</span><input type="text" name="finalPrice" value="" size="5" /><br />
<span>Rounded Price: $</span><input type="text" name="roundedPrice" value="" size="5" /><br />
<span>Profit Made: $</span><input type="text" name="profitMade" value="" size="5" /><br />
<span>Rounded Profit: $</span><input type="text" name="roundedProfit" value="" size="5" />
</p>
<p><input type="button" name="calculateButton" value="Calculate" onclick="calculate()" /> <input type="button" name="resetButton" value="Reset" onclick="formReset()" /></p>
</form>
</td>
</tr>
</table>
<p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a> <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a></p>
</body>
</html>
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- This scripting was scripted by ninjinsamax3. This is opened sourced, so please edited as you wish, but please give some credit. Thank you. -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy for Linux (vers 1 September 2005), see www.w3.org" />
<title>Profit Calculator V0 REV0.0</title>
<style type="text/css">
/*<![CDATA[*/
span {font-weight:bold;}
img {border:0px;}
/*]]>*/
</style>
</head>
<body>
<script type="text/javascript">
//<![CDATA[
function calculateTax(tax, price)
{
return tax * price;
}
function calculateProfit(price, profit)
{
return (price * profit) / 100;
}
function calculate()
{
var sTax = Number(document.form.stateTax.value) / 100;
var sPrice = Number(document.form.salesPrice.value);
var pWanted = Number(document.form.profitWanted.value);
var shPrice = Number(document.form.shippingPrice.value);
var saTax = calculateTax(sTax, sPrice);
var pPrice = calculateProfit(sPrice, pWanted) + sPrice;
var fPrice = pPrice + calculateTax(sTax, pPrice) +shPrice;
var fPST = fPrice - shPrice - pPrice;
var sTD = fPST - saTax;
var pMade = fPrice - shPrice - sPrice;
document.form.salesTax.value = saTax.toFixed(2)
document.form.finalPrice.value = fPrice.toFixed(2);
document.form.finalPriceSalesTax.value = fPST.toFixed(2);
document.form.roundedPrice.value = fPrice.toFixed(0);
document.form.roundedPriceSalesTax.value = fPST.toFixed(2);
document.form.salesTaxDifference.value = sTD.toFixed(2);
document.form.profitMade.value = pMade.toFixed(2);
document.form.roundedProfit.value = pMade.toFixed(0);
}
function formReset()
{
document.getElementById("form").reset()
}
//]]>
</script>
<table>
<tr>
<td>
<form name="form" id="form" action=""><p><span>*State Tax: </span><input type="text" name="stateTax" value="8.375" size="5" /><span>%</span><br />
<span>*Sales Price: $</span><input type="text" name="salesPrice" value="" size="5" /><br />
<span>*Profit Wanted: </span><input type="text" name="profitWanted" value="" size="5" /><span>%</span><br />
<span>*Shipping Price: $</span><input type="text" name="shippingPrice" value="" size="5" /><br />
<span>Sales Tax: $</span><input type="text" name="salesTax" value="" size="5" /><span></span><br />
<span>Final Price: $</span><input type="text" name="finalPrice" value="" size="5" /><br />
<span>Final Price Sales Tax: $</span><input type="text" name="finalPriceSalesTax" value="" size="5" /><span></span><br />
<span>Rounded Price: $</span><input type="text" name="roundedPrice" value="" size="5" /><br />
<span>Rounded Price Sales Tax: </span><input type="text" name="roundedPriceSalesTax" value="" size="5" /><span></span><br />
<span>Profit Made: $</span><input type="text" name="profitMade" value="" size="5" /><br />
<span>Rounded Profit: $</span><input type="text" name="roundedProfit" value="" size="5" /><br />
<span>Original & Final Sales Tax Difference: $</span><input type="text" name="salesTaxDifference" value="" size="5" />
</p>
<p><input type="button" name="calculateButton" value="Calculate" onclick="calculate()" /> <input type="button" name="resetButton" value="Reset" onclick="formReset()" /></p>
</form>
</td>
</tr>
</table>
<p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a> <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a></p>
</body>
</html>








