Welcome to Earthbound.darkbb.com
Please login or Register and Join the free community!
Registering allows access to _Invisible Sections_.


 :: Coding

Go down


Post by BIGB0T on Sun Aug 12, 2012 6:56 am

Ok so I know you guys going to criticize me on my how name my Variables, LOL yes I know they have no relevance but I cooked up this code for a friend who wanted to know how to make a two number calculator.

Description: So the first 7 lines are self explanatory so I'm not going to spend much time on that so just for a quick overview the imports are to initiate Java and the JOptionPane method for displaying. Public #### is to name the #### of your prgramme, public static void main (String[]args) Tells your IDE Where to start reading code from.

Then we have 3 Input lines two converting the input to integers since JOptionPane can only handle String, the third one is to input the calculation symbol. Names = Names.trim(); First time seeing that? It's a simple method used to trim out extra spaces from a variable to avoid any spaces causing errors.

Then I have four IF statements for the calculations ( Addition, Subtraction, Multiplication and Division) and the last one for validation purposes so that it returns to add a symbol if an Incorrect one was entered.

Feel free to ask any questions. alien

Posts : 26
Points : 60
Reputation : 0
Join date : 2011-06-02
Age : 25
Location : Durban

View user profile http://earthbound.darkbb.com

Back to top Go down

Back to top

 :: Coding

Permissions in this forum:
You cannot reply to topics in this forum