Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Java 

[TUT]Your First Calculator in Four Easy Steps[TUT]

Nice Calculator, more advanced than the calculator at
http://www.youtube.com/watch?v=ANuuSFY2B...9D83EE3E28
😁
(Feb 21, 2010 06:42 PM)eXero Wrote:  there is no need to devide by zero.
I think you misunderstood...

lol
(Feb 21, 2010 07:01 PM)eXero Wrote:  dude, if you dont like my tut get off my thread. this tut id advanced because the most basic calculators that someone makes in java are only able to do one operation, so this one can do all of them. therefore it is advanced.

It's not really a tutorial - you never explain how the code works.
Why are you guys constantly flaming him for sharing a calculator he wrote? You don't have to keep bashing him telling him it's "Not advanced enough". It's a calculator.
How is pointing out a lack of explanation flaming?
It just seemed like you guys were flaming him for no reason, all he was doing was sharing his calculator. Nevermind.
Good basic calculator,


Slightly modified to so it gives you an error when you divide by zero unless you divide 0 by 0 itself if your interested...

Spoiler (Click to View)



I am not flaming, just posting this if you wanted to find out how to fix this 'problem'.
I like it..I mean im not into Java im into Python but still this is a good and easy tutorial even I could understand.
Thanks Mate =). This was helpful. Good Share.
I know i'm bringing this thread back from the grave, but I am a just starting java as of Wednesday and I was wondering if it was possible to put a space between the numbers. I put a space around the " = " so the result and second number would be space out, but my problem was figuring out a way to put a space around the operator. Since operator could be 1 of 4 commands, how would you right the if statement for each command to put a space around the operator. If you know what I'm trying to describe...
yeah, that's exactly what I meant! I tried to put the space between the + signs like
Code
System.out.println(num1 " " + operator " " + num2 + " = " + result);

when using a space in a calculation, do you always put (+) around a space? so it prints it or how does that work?

and thanks once again Ben!
How is this an advanced calculator?
(Nov 13, 2010 08:20 PM)JBow94 Wrote:  How is this an advanced calculator?

read the entire post and you'll see that your post was redundant
(Nov 14, 2010 12:28 AM)pro-phecy Wrote:  read the entire post and you'll see that your post was redundant

Nah bro 😅

It's a public forum for public opinions, if that's how I feel, I can most certainly express it 👍
(Nov 14, 2010 07:17 AM)JBow94 Wrote:  Nah bro 😅

It's a public forum for public opinions, if that's how I feel, I can most certainly express it 👍

I'm not saying you can't express it, but your question and answer has already been posed and answered, which makes it "seem" redundant.
(Nov 13, 2010 09:44 AM)pro-phecy Wrote:  I know i'm bringing this thread back from the grave, but I am a just starting java as of Wednesday and I was wondering if it was possible to put a space between the numbers. I put a space around the " = " so the result and second number would be space out, but my problem was figuring out a way to put a space around the operator. Since operator could be 1 of 4 commands, how would you right the if statement for each command to put a space around the operator. If you know what I'm trying to describe...

I'm not 100% sure what you're asking but maybe this little snippet of code will help:

Code
System.out.println(String.format("1 + 2 = %1$d", 1 + 2));

Try that, is that what you meant by "space around the operator"?


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by ScrewbaccaDec 2, 2016 10:50 AM 19 1,365 Dec 2, 2016 10:50 AM
Last Post: Goodies
[C] by NielyMar 22, 2014 08:21 AM 8 210 Mar 22, 2014 08:21 AM
Last Post: Niely
[.NET] by KeeloFeb 9, 2013 10:39 PM 5 400 Feb 9, 2013 10:39 PM
Last Post: 0xDEAD10CC