New Posts  All Forums:Forum Nav:

Profit Calculator

post #1 of 24
Thread Starter 
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
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>
Profit Calculator V1 REV0.
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>
    
CPUMotherboardGraphicsRAM
Intel Mobile Core 2 Duo P8600 2.4Ghz ASUS N50Vn-X1B ASUS NVIDIA GeForce 9650M GT 4GB DDR2 
Hard DriveOptical DriveOSMonitor
250GB SATA 5400rpm DVD Super Multi Windows 7 Professional 64bit 15.4" WXGA/LED 
KeyboardPowerCaseMouse
ASUS Laptop Extended Keyboard 6-Cell Lithium Ion Battery & 90-watt AC adapter ASUS N50Vn-X1B Logitech VX Nano 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Intel Mobile Core 2 Duo P8600 2.4Ghz ASUS N50Vn-X1B ASUS NVIDIA GeForce 9650M GT 4GB DDR2 
Hard DriveOptical DriveOSMonitor
250GB SATA 5400rpm DVD Super Multi Windows 7 Professional 64bit 15.4" WXGA/LED 
KeyboardPowerCaseMouse
ASUS Laptop Extended Keyboard 6-Cell Lithium Ion Battery & 90-watt AC adapter ASUS N50Vn-X1B Logitech VX Nano 
  hide details  
Reply
post #2 of 24
pretty simple, yet effective...

I could toss something together in C++ so you can have a stand alone exe file... interested?
good enough
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6600 3ghz Gigabyte GA-EP45-DS3L 9800GT 2x2gb fatility DDR2 1066 
Hard DriveOSMonitorMouse
2 x 74gb raptor raid0 win7 64bit Samsung 245BW Razer 3G diamondback 
Mouse Pad
glass core pad 
  hide details  
Reply
good enough
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6600 3ghz Gigabyte GA-EP45-DS3L 9800GT 2x2gb fatility DDR2 1066 
Hard DriveOSMonitorMouse
2 x 74gb raptor raid0 win7 64bit Samsung 245BW Razer 3G diamondback 
Mouse Pad
glass core pad 
  hide details  
Reply
post #3 of 24
Thread Starter 
Yeah. I never learned C++, but only Java and yet, I do not know how to make Jar files because making one was too difficult for me. If you could give some pointers for the C++ and executable files that would be nice. Thank you in advance.
    
CPUMotherboardGraphicsRAM
Intel Mobile Core 2 Duo P8600 2.4Ghz ASUS N50Vn-X1B ASUS NVIDIA GeForce 9650M GT 4GB DDR2 
Hard DriveOptical DriveOSMonitor
250GB SATA 5400rpm DVD Super Multi Windows 7 Professional 64bit 15.4" WXGA/LED 
KeyboardPowerCaseMouse
ASUS Laptop Extended Keyboard 6-Cell Lithium Ion Battery & 90-watt AC adapter ASUS N50Vn-X1B Logitech VX Nano 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Intel Mobile Core 2 Duo P8600 2.4Ghz ASUS N50Vn-X1B ASUS NVIDIA GeForce 9650M GT 4GB DDR2 
Hard DriveOptical DriveOSMonitor
250GB SATA 5400rpm DVD Super Multi Windows 7 Professional 64bit 15.4" WXGA/LED 
KeyboardPowerCaseMouse
ASUS Laptop Extended Keyboard 6-Cell Lithium Ion Battery & 90-watt AC adapter ASUS N50Vn-X1B Logitech VX Nano 
  hide details  
Reply
post #4 of 24
yeah sure...

I'll toss something together, and give you the source and the exe...

Go download "bloodshed" its a fairly easy to use c++ compiler, and its free...
good enough
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6600 3ghz Gigabyte GA-EP45-DS3L 9800GT 2x2gb fatility DDR2 1066 
Hard DriveOSMonitorMouse
2 x 74gb raptor raid0 win7 64bit Samsung 245BW Razer 3G diamondback 
Mouse Pad
glass core pad 
  hide details  
Reply
good enough
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6600 3ghz Gigabyte GA-EP45-DS3L 9800GT 2x2gb fatility DDR2 1066 
Hard DriveOSMonitorMouse
2 x 74gb raptor raid0 win7 64bit Samsung 245BW Razer 3G diamondback 
Mouse Pad
glass core pad 
  hide details  
Reply
post #5 of 24
i have something going, but its not quite working yet...

Do you charge tax before or after shipping costs??

also, you state that the tax is 0.08375. Does this mean 8.375 cents per dollar?
good enough
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6600 3ghz Gigabyte GA-EP45-DS3L 9800GT 2x2gb fatility DDR2 1066 
Hard DriveOSMonitorMouse
2 x 74gb raptor raid0 win7 64bit Samsung 245BW Razer 3G diamondback 
Mouse Pad
glass core pad 
  hide details  
Reply
good enough
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6600 3ghz Gigabyte GA-EP45-DS3L 9800GT 2x2gb fatility DDR2 1066 
Hard DriveOSMonitorMouse
2 x 74gb raptor raid0 win7 64bit Samsung 245BW Razer 3G diamondback 
Mouse Pad
glass core pad 
  hide details  
Reply
post #6 of 24
Quote:
var priceWithStateTax = (priceWithProfitWanted * stateTax) + priceWithProfitWanted;
Never mind, answered my own question. Sales tax is to be applied after shipping fees...

I live in Oregon, so tax isn't an issue, or something that i have to deal with often
good enough
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6600 3ghz Gigabyte GA-EP45-DS3L 9800GT 2x2gb fatility DDR2 1066 
Hard DriveOSMonitorMouse
2 x 74gb raptor raid0 win7 64bit Samsung 245BW Razer 3G diamondback 
Mouse Pad
glass core pad 
  hide details  
Reply
good enough
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6600 3ghz Gigabyte GA-EP45-DS3L 9800GT 2x2gb fatility DDR2 1066 
Hard DriveOSMonitorMouse
2 x 74gb raptor raid0 win7 64bit Samsung 245BW Razer 3G diamondback 
Mouse Pad
glass core pad 
  hide details  
Reply
post #7 of 24
Here is the code i put together. The logic is the same as javascript, and similar with declaring variables. "float" gives the variable your calculating more precision, so you can apply cents the the cost.

Let me know if there's something wrong with it, or you need clarification with something...

i also attached the exe file, so you can play around with it and verify it.

Code:
#include <iostream>                 //Required if your program does any I/O
#include <string>                   //Required if your program uses C++ strings
#include <iomanip>                  //Allows I/O Manipulation
using namespace std;                //Required for ANSI C++ 1998 standard.

int main (int argc, char **argv)    //Arguments to main are command line arguments
{
    char reply;                     //A character variable to hold user input

    float stateTax = 0.08375; 
    float profitWanted;             
    float costPrice;              
    float shippingCost;             
    float salePriceWithTax;
    float costPriceWithProfit; 
    float priceAterTaxAndShipping;           
    
    cout << "Welcom to JoBlo69's Profit Calculator!" << endl;
    cout << 'n';
    
    cout << "Please enter Item's price : ";
    cin >> costPrice;
    cout << "Please enter shipping cost : ";
    cin >> shippingCost;
    cout << "Enter profit wanted : ";
    cin >> profitWanted;
    cout << 'n';
    
    salePriceWithTax = (stateTax * costPrice) + costPrice;
    costPriceWithProfit = salePriceWithTax + profitWanted;
    priceAterTaxAndShipping = salePriceWithTax + shippingCost;
    
    cout << "Cost of item with tax : " << salePriceWithTax << endl;
    cout << 'n';
    cout << "Cost of item with profit, and tax : " << costPriceWithProfit << endl;
    cout << 'n';
    cout << "Cost of item with profit, tax and shipping : " << priceAterTaxAndShipping << endl;
    cout << 'n';
    
    cout << "Press any key followed by 'Enter' to quit: ";
    cin >> reply;
    return 0;
}
good enough
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6600 3ghz Gigabyte GA-EP45-DS3L 9800GT 2x2gb fatility DDR2 1066 
Hard DriveOSMonitorMouse
2 x 74gb raptor raid0 win7 64bit Samsung 245BW Razer 3G diamondback 
Mouse Pad
glass core pad 
  hide details  
Reply
good enough
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6600 3ghz Gigabyte GA-EP45-DS3L 9800GT 2x2gb fatility DDR2 1066 
Hard DriveOSMonitorMouse
2 x 74gb raptor raid0 win7 64bit Samsung 245BW Razer 3G diamondback 
Mouse Pad
glass core pad 
  hide details  
Reply
post #8 of 24
Thread Starter 
That's nice.

C++ is a little different from Java, but what did you use to create the executable file?
    
CPUMotherboardGraphicsRAM
Intel Mobile Core 2 Duo P8600 2.4Ghz ASUS N50Vn-X1B ASUS NVIDIA GeForce 9650M GT 4GB DDR2 
Hard DriveOptical DriveOSMonitor
250GB SATA 5400rpm DVD Super Multi Windows 7 Professional 64bit 15.4" WXGA/LED 
KeyboardPowerCaseMouse
ASUS Laptop Extended Keyboard 6-Cell Lithium Ion Battery & 90-watt AC adapter ASUS N50Vn-X1B Logitech VX Nano 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Intel Mobile Core 2 Duo P8600 2.4Ghz ASUS N50Vn-X1B ASUS NVIDIA GeForce 9650M GT 4GB DDR2 
Hard DriveOptical DriveOSMonitor
250GB SATA 5400rpm DVD Super Multi Windows 7 Professional 64bit 15.4" WXGA/LED 
KeyboardPowerCaseMouse
ASUS Laptop Extended Keyboard 6-Cell Lithium Ion Battery & 90-watt AC adapter ASUS N50Vn-X1B Logitech VX Nano 
  hide details  
Reply
post #9 of 24
i used "bloodshed" its an open source C++ compiler.

It looks like a really advanced note pad app. But with options to compile your code into an .exe...

The text file is simply a .cpp file. Think of it as a .txt file with a different file extension. The compiler, reads this file, and makes another file (the .exe) on the most basic level, machine code, aka binary 1's and 0's.
good enough
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6600 3ghz Gigabyte GA-EP45-DS3L 9800GT 2x2gb fatility DDR2 1066 
Hard DriveOSMonitorMouse
2 x 74gb raptor raid0 win7 64bit Samsung 245BW Razer 3G diamondback 
Mouse Pad
glass core pad 
  hide details  
Reply
good enough
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6600 3ghz Gigabyte GA-EP45-DS3L 9800GT 2x2gb fatility DDR2 1066 
Hard DriveOSMonitorMouse
2 x 74gb raptor raid0 win7 64bit Samsung 245BW Razer 3G diamondback 
Mouse Pad
glass core pad 
  hide details  
Reply
post #10 of 24
Thread Starter 
Only for C++ right and not for Java? I wish there was something for Java easy to do, since I'm not familiar with C++, I can understand a bit by looking, but actually writing impossible for me. Though, repping for helping me make it into an executable file. Thanks.
    
CPUMotherboardGraphicsRAM
Intel Mobile Core 2 Duo P8600 2.4Ghz ASUS N50Vn-X1B ASUS NVIDIA GeForce 9650M GT 4GB DDR2 
Hard DriveOptical DriveOSMonitor
250GB SATA 5400rpm DVD Super Multi Windows 7 Professional 64bit 15.4" WXGA/LED 
KeyboardPowerCaseMouse
ASUS Laptop Extended Keyboard 6-Cell Lithium Ion Battery & 90-watt AC adapter ASUS N50Vn-X1B Logitech VX Nano 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Intel Mobile Core 2 Duo P8600 2.4Ghz ASUS N50Vn-X1B ASUS NVIDIA GeForce 9650M GT 4GB DDR2 
Hard DriveOptical DriveOSMonitor
250GB SATA 5400rpm DVD Super Multi Windows 7 Professional 64bit 15.4" WXGA/LED 
KeyboardPowerCaseMouse
ASUS Laptop Extended Keyboard 6-Cell Lithium Ion Battery & 90-watt AC adapter ASUS N50Vn-X1B Logitech VX Nano 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Web Coding