Nice Calculator, more advanced than the calculator at
http://www.youtube.com/watch?v=ANuuSFY2B...9D83EE3E28
😁
http://www.youtube.com/watch?v=ANuuSFY2B...9D83EE3E28
😁
|
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.
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 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! (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 |