Overclock.net banner

Profit Calculator

3957 Views 23 Replies 8 Participants Last post by  fashionnugget
4
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:
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. -->

Profit Calculator V0 REV0.1

[TABLE]
[TR]
[TD]

*Sales Price: $
*Profit Wanted: %
*Shipping Price: $
Final Price: $
Rounded Price: $
Profit Made: $
Rounded Profit: $

[/TD]
[/TR]
[/TABLE]

[URL=http://validator.w3.org/check?uri=referer][IMG alt="Valid XHTML 1.0 Transitional"]http://www.w3.org/Icons/valid-xhtml10[/IMG][/URL] [URL=http://validator.w3.org/check?uri=referer][IMG alt="Valid XHTML 1.0 Transitional"]http://www.w3.org/Icons/valid-xhtml10-blue[/IMG][/URL]
Profit Calculator V1 REV0.

Code:
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. -->

Profit Calculator V0 REV0.0

[TABLE]
[TR]
[TD]

*State Tax: %
*Sales Price: $
*Profit Wanted: %
*Shipping Price: $
Sales Tax: $
Final Price: $
Final Price Sales Tax: $
Rounded Price: $
Rounded Price Sales Tax: 
Profit Made: $
Rounded Profit: $
Original & Final Sales Tax Difference: $

[/TD]
[/TR]
[/TABLE]

[URL=http://validator.w3.org/check?uri=referer][IMG alt="Valid XHTML 1.0 Transitional"]http://www.w3.org/Icons/valid-xhtml10[/IMG][/URL] [URL=http://validator.w3.org/check?uri=referer][IMG alt="Valid XHTML 1.0 Transitional"]http://www.w3.org/Icons/valid-xhtml10-blue[/IMG][/URL]
See less See more
  • Rep+
Reactions: 1
1 - 20 of 24 Posts
pretty simple, yet effective...

I could toss something together in C++ so you can have a stand alone exe file... interested?
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.
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...
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?
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
See less See more
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:
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;
}
See less See more
That's nice.

C++ is a little different from Java, but what did you use to create the executable file?
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.
  • Rep+
Reactions: 1
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.
I'm not to familiar with java, not sure how to go about making a stand alone with java.

But if this doesn't do something correctly, or you want it changed up, let me know the specifics of what needs to be done, and I'll make another revision of the app, no big deal...

With all programming languages, you only really need to learn differences in syntax and order of operations within any given language. The logic is all the same across the board. Minor differences here and their, but its generally all the same. Some languages are better suited for specific things, some are not. Like Java script for instance, its real good at embedding into web pages because there is nothing to compile. C++ is great for stand alone apps. C++ is also very much portable when you follow the generally excepted guidelines. So if you were to take this cpp file i posted, and opened it into a C++ compiler in Linux, it would do the same thing as it does in windows...
Yes, I understand that much for that part. That is one thing I dislike about Java. You also need to have Java Runtime for running Java applications and scripts. It works fine. Thank you.
This is best handled in Visual Basic.
^ Haven't really learned that. I can only do Java, and then since Java is close with Javascript, I wrote this using Javascript. For some reason, I can never get the Jar files to work, even before that, I cannot even create one. That is why I wished I learned C++. lol
2
Quote:


Originally Posted by ninjinsamax3
View Post

^ Haven't really learned that. I can only do Java, and then since Java is close with Javascript, I wrote this using Javascript. For some reason, I can never get the Jar files to work, even before that, I cannot even create one. That is why I wished I learned C++. lol

What do you mean by "Java is close with Javascript"
It's really not lol.
See less See more
^ lmao, well to me it is, since if I could write Javascript that means it would have to have dealt with Java. But usually I can understand C, but not be able to write it.
Quote:

Originally Posted by ninjinsamax3 View Post
^ lmao, well to me it is, since if I could write Javascript that means it would have to have dealt with Java. But usually I can understand C, but not be able to write it.
Javascript and Java are in no way related. Other than those first 4 letters...
See less See more
If you'd like, i could host the thing on the internet
It's no problem. If you want to you can, I just bring it handy for myself to use. But that is a good idea hosting it. Someone on OCN has given me a web space. I appreciate your thought though!
Hey Ninjin Download Eclipse for Java, its open source compiler and its pretty sweet, helps you out a lot if you make a mistake, visual basics is fairly easy to learn..its mainly interface coding...so its not much of the actual code involved..umm for C++ id say also use Eclipse, since there u can pick between java and c++ Ive personally have taken 6 classes on Coding for 4 years right now taking my 7th....the classes dont really help a lot but its a good way to make your coding abilities better. But um yeah try eclipse or bluebird, either one works If you need help pm me xD
1 - 20 of 24 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top