Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Web Coding

Reply
 
LinkBack Thread Tools
Old 02-10-08   #1 (permalink)
New to Overclock.net
 
ninjinsamax3's Avatar
 
intel nvidia

Join Date: Oct 2007
Location: New York
Posts: 1,082

Rep: 81 ninjinsamax3 is acknowledged by some
Unique Rep: 67
Hardware Reviews: 2
Trader Rating: 0
Default Profit Calculator

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>
Attached Files
File Type: rar Profit Calculator V1 REV0.0.rar (1.2 KB, 7 views)
File Type: rar Profit Calculator V0 REV0.1.rar (1.1 KB, 6 views)
__________________
キャントジャパンニースのプライド!!
初音ミクの歌を聞かないけど、
彼女のキャラがズット大好きで、
可愛くてたまらないと思うんです。

Program: Profit Calculator

System: fuyuki.
CPU
Intel Pentium 4 Northwood CPU 2.53GHz
Motherboard
Dell Computer Corporation Dimension 8200
Memory
Samsung RDRAM PC800-40 (400MHz)
Graphics Card
Nvidia Corp GeForce4 MX 420
Hard Drive
1xWDC(80GB),1xST3300831A(200GB)
Power Supply
SPARKLE ATX-300GT ATX 300W Power Supply
Case
Dell Dimension 8200 Chasis Mini Tower
CPU cooling
1xStock Heatsink(Back case fan)
GPU cooling
Air
OS
Microsoft Windows XP Professional Version 2002 SP2
Monitor
Dell Computer DELL 1800FP

Last edited by ninjinsamax3 : 02-11-08 at 10:33 PM.
ninjinsamax3 is offline   Reply With Quote
Old 02-10-08   #2 (permalink)
Programmer
 
JoBlo69's Avatar
 
intel nvidia

Join Date: Jan 2007
Posts: 3,297

Rep: 168 JoBlo69 is acknowledged by manyJoBlo69 is acknowledged by many
Unique Rep: 145
Folding Team Rank: 550
Trader Rating: 15
Default

pretty simple, yet effective...

I could toss something together in C++ so you can have a stand alone exe file... interested?
__________________
My Lego case thread. With PICS!!!
-----------------------------------------------------------------------
Video card RMA database thread. I am working on an application that allows users to input their cards issues into a database, to build a knowledge base for what types of cards have a lower fail rate.

System: 45nm FTW
CPU
E8400 3.6Ghz 1.25v
Motherboard
ASUS P5Q Delux P45
Memory
4GB (2x2GB) PATRIOT Viper PVS24G 6400LLK R
Graphics Card
XFX 8800GT
Hard Drive
2 x 74GB Raptors RAID0 ICH10R
Sound Card
onboard (not so hot)
Power Supply
700w OCZ GamerXtream
Case
Spread Across My Desk...
OS
64 bit Vista Ult.
Monitor
Samsung 245BW + 18" Dell LCD
JoBlo69 is online now I fold for Overclock.net JoBlo69's Gallery   Reply With Quote
Old 02-10-08   #3 (permalink)
New to Overclock.net
 
ninjinsamax3's Avatar
 
intel nvidia

Join Date: Oct 2007
Location: New York
Posts: 1,082

Rep: 81 ninjinsamax3 is acknowledged by some
Unique Rep: 67
Hardware Reviews: 2
Trader Rating: 0
Default

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.
__________________
キャントジャパンニースのプライド!!
初音ミクの歌を聞かないけど、
彼女のキャラがズット大好きで、
可愛くてたまらないと思うんです。

Program: Profit Calculator

System: fuyuki.
CPU
Intel Pentium 4 Northwood CPU 2.53GHz
Motherboard
Dell Computer Corporation Dimension 8200
Memory
Samsung RDRAM PC800-40 (400MHz)
Graphics Card
Nvidia Corp GeForce4 MX 420
Hard Drive
1xWDC(80GB),1xST3300831A(200GB)
Power Supply
SPARKLE ATX-300GT ATX 300W Power Supply
Case
Dell Dimension 8200 Chasis Mini Tower
CPU cooling
1xStock Heatsink(Back case fan)
GPU cooling
Air
OS
Microsoft Windows XP Professional Version 2002 SP2
Monitor
Dell Computer DELL 1800FP
ninjinsamax3 is offline   Reply With Quote
Old 02-10-08   #4 (permalink)
Programmer
 
JoBlo69's Avatar
 
intel nvidia

Join Date: Jan 2007
Posts: 3,297

Rep: 168 JoBlo69 is acknowledged by manyJoBlo69 is acknowledged by many
Unique Rep: 145
Folding Team Rank: 550
Trader Rating: 15
Default

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...
__________________
My Lego case thread. With PICS!!!
-----------------------------------------------------------------------
Video card RMA database thread. I am working on an application that allows users to input their cards issues into a database, to build a knowledge base for what types of cards have a lower fail rate.

System: 45nm FTW
CPU
E8400 3.6Ghz 1.25v
Motherboard
ASUS P5Q Delux P45
Memory
4GB (2x2GB) PATRIOT Viper PVS24G 6400LLK R
Graphics Card
XFX 8800GT
Hard Drive
2 x 74GB Raptors RAID0 ICH10R
Sound Card
onboard (not so hot)
Power Supply
700w OCZ GamerXtream
Case
Spread Across My Desk...
OS
64 bit Vista Ult.
Monitor
Samsung 245BW + 18" Dell LCD
JoBlo69 is online now I fold for Overclock.net JoBlo69's Gallery   Reply With Quote
Old 02-10-08   #5 (permalink)
Programmer
 
JoBlo69's Avatar
 
intel nvidia

Join Date: Jan 2007
Posts: 3,297

Rep: 168 JoBlo69 is acknowledged by manyJoBlo69 is acknowledged by many
Unique Rep: 145
Folding Team Rank: 550
Trader Rating: 15
Default

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?
__________________
My Lego case thread. With PICS!!!
-----------------------------------------------------------------------
Video card RMA database thread. I am working on an application that allows users to input their cards issues into a database, to build a knowledge base for what types of cards have a lower fail rate.

System: 45nm FTW
CPU
E8400 3.6Ghz 1.25v
Motherboard
ASUS P5Q Delux P45
Memory
4GB (2x2GB) PATRIOT Viper PVS24G 6400LLK R
Graphics Card
XFX 8800GT
Hard Drive
2 x 74GB Raptors RAID0 ICH10R
Sound Card
onboard (not so hot)
Power Supply
700w OCZ GamerXtream
Case
Spread Across My Desk...
OS
64 bit Vista Ult.
Monitor
Samsung 245BW + 18" Dell LCD
JoBlo69 is online now I fold for Overclock.net JoBlo69's Gallery   Reply With Quote
Old 02-10-08   #6 (permalink)
Programmer
 
JoBlo69's Avatar
 
intel nvidia

Join Date: Jan 2007
Posts: 3,297

Rep: 168 JoBlo69 is acknowledged by manyJoBlo69 is acknowledged by many
Unique Rep: 145
Folding Team Rank: 550
Trader Rating: 15
Default

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 :P
__________________
My Lego case thread. With PICS!!!
-----------------------------------------------------------------------
Video card RMA database thread. I am working on an application that allows users to input their cards issues into a database, to build a knowledge base for what types of cards have a lower fail rate.

System: 45nm FTW
CPU
E8400 3.6Ghz 1.25v
Motherboard
ASUS P5Q Delux P45
Memory
4GB (2x2GB) PATRIOT Viper PVS24G 6400LLK R
Graphics Card
XFX 8800GT
Hard Drive
2 x 74GB Raptors RAID0 ICH10R
Sound Card
onboard (not so hot)
Power Supply
700w OCZ GamerXtream
Case
Spread Across My Desk...
OS
64 bit Vista Ult.
Monitor
Samsung 245BW + 18" Dell LCD
JoBlo69 is online now I fold for Overclock.net JoBlo69's Gallery   Reply With Quote
Old 02-10-08   #7 (permalink)
Programmer
 
JoBlo69's Avatar
 
intel nvidia

Join Date: Jan 2007
Posts: 3,297

Rep: 168 JoBlo69 is acknowledged by manyJoBlo69 is acknowledged by many
Unique Rep: 145
Folding Team Rank: 550
Trader Rating: 15
Default

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;
}
Attached Files
File Type: rar profitCalc.rar (104.2 KB, 14 views)
__________________
My Lego case thread. With PICS!!!
-----------------------------------------------------------------------
Video card RMA database thread. I am working on an application that allows users to input their cards issues into a database, to build a knowledge base for what types of cards have a lower fail rate.

System: 45nm FTW
CPU
E8400 3.6Ghz 1.25v
Motherboard
ASUS P5Q Delux P45
Memory
4GB (2x2GB) PATRIOT Viper PVS24G 6400LLK R
Graphics Card
XFX 8800GT
Hard Drive
2 x 74GB Raptors RAID0 ICH10R
Sound Card
onboard (not so hot)
Power Supply
700w OCZ GamerXtream
Case
Spread Across My Desk...
OS
64 bit Vista Ult.
Monitor
Samsung 245BW + 18" Dell LCD
JoBlo69 is online now I fold for Overclock.net JoBlo69's Gallery   Reply With Quote
Old 02-10-08   #8 (permalink)
New to Overclock.net
 
ninjinsamax3's Avatar
 
intel nvidia

Join Date: Oct 2007
Location: New York
Posts: 1,082

Rep: 81 ninjinsamax3 is acknowledged by some
Unique Rep: 67
Hardware Reviews: 2
Trader Rating: 0
Default

That's nice.

C++ is a little different from Java, but what did you use to create the executable file?
__________________
キャントジャパンニースのプライド!!
初音ミクの歌を聞かないけど、
彼女のキャラがズット大好きで、
可愛くてたまらないと思うんです。

Program: Profit Calculator

System: fuyuki.
CPU
Intel Pentium 4 Northwood CPU 2.53GHz
Motherboard
Dell Computer Corporation Dimension 8200
Memory
Samsung RDRAM PC800-40 (400MHz)
Graphics Card
Nvidia Corp GeForce4 MX 420
Hard Drive
1xWDC(80GB),1xST3300831A(200GB)
Power Supply
SPARKLE ATX-300GT ATX 300W Power Supply
Case
Dell Dimension 8200 Chasis Mini Tower
CPU cooling
1xStock Heatsink(Back case fan)
GPU cooling
Air
OS
Microsoft Windows XP Professional Version 2002 SP2
Monitor
Dell Computer DELL 1800FP
ninjinsamax3 is offline   Reply With Quote
Old 02-10-08   #9 (permalink)
Programmer
 
JoBlo69's Avatar
 
intel nvidia

Join Date: Jan 2007
Posts: 3,297

Rep: 168 JoBlo69 is acknowledged by manyJoBlo69 is acknowledged by many
Unique Rep: 145
Folding Team Rank: 550
Trader Rating: 15
Default

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.
__________________
My Lego case thread. With PICS!!!
-----------------------------------------------------------------------
Video card RMA database thread. I am working on an application that allows users to input their cards issues into a database, to build a knowledge base for what types of cards have a lower fail rate.

System: 45nm FTW
CPU
E8400 3.6Ghz 1.25v
Motherboard
ASUS P5Q Delux P45
Memory
4GB (2x2GB) PATRIOT Viper PVS24G 6400LLK R
Graphics Card
XFX 8800GT
Hard Drive
2 x 74GB Raptors RAID0 ICH10R
Sound Card
onboard (not so hot)
Power Supply
700w OCZ GamerXtream
Case
Spread Across My Desk...
OS
64 bit Vista Ult.
Monitor
Samsung 245BW + 18" Dell LCD
JoBlo69 is online now I fold for Overclock.net JoBlo69's Gallery   Reply With Quote
Old 02-10-08   #10 (permalink)
New to Overclock.net
 
ninjinsamax3's Avatar
 
intel nvidia

Join Date: Oct 2007
Location: New York
Posts: 1,082

Rep: 81 ninjinsamax3 is acknowledged by some
Unique Rep: 67
Hardware Reviews: 2
Trader Rating: 0
Default

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.
__________________
キャントジャパンニースのプライド!!
初音ミクの歌を聞かないけど、
彼女のキャラがズット大好きで、
可愛くてたまらないと思うんです。

Program: Profit Calculator

System: fuyuki.
CPU
Intel Pentium 4 Northwood CPU 2.53GHz
Motherboard
Dell Computer Corporation Dimension 8200
Memory
Samsung RDRAM PC800-40 (400MHz)
Graphics Card
Nvidia Corp GeForce4 MX 420
Hard Drive
1xWDC(80GB),1xST3300831A(200GB)
Power Supply
SPARKLE ATX-300GT ATX 300W Power Supply
Case
Dell Dimension 8200 Chasis Mini Tower
CPU cooling
1xStock Heatsink(Back case fan)
GPU cooling
Air
OS
Microsoft Windows XP Professional Version 2002 SP2
Monitor
Dell Computer DELL 1800FP
ninjinsamax3 is offline   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -4. The time now is 02:50 AM.


Overclock.net is a Carbon Neutral Site Creative Commons License Internet Security By ControlScan

Terms of Service / Forum Rules | Privacy Policy | Advertising | Become an Official Vendor
Copyright © 2008 Shogun Interactive Development. Most rights reserved.
Page generated in 0.21322 seconds with 10 queries