How To Make A Simple Calculator in Java PDF
How To Make A Simple Calculator in Java PDF
Table of Contents
Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
http://www.instructables.com/id/How-to-Make-a-Simple-Calculator-in-Java/
Intro: How to Make a Simple Calculator in Java
After the "Hello World!" program, a calculator is one of the first things a programmer will learn to build in their introduction to coding. The reason for this is because of the
simplicity of its structure in addition to covering most of the basic concepts in programming. Follow the steps below and you too will be able to build your own fully
functioning calculator!
http://www.instructables.com/id/How-to-Make-a-Simple-Calculator-in-Java/
Step 3: Declare Inputs
As mentioned in the last step, all methods follow the IPO structure, short for input, process, output structure. This means that in short all methods receive some form of
input, perform a process, and return an output. First we're going to declare the inputs. Inputs can be of different data types so we have to be specific in our declaration.
The main data types are int(i.e. 1, 2, 3...), double (i.e. 1.0, 2.7, 0.8....), char(a,b,c,d,+,-,#...), and string(hello, yes, hi, word up....). For our example we need to declare two
int type numbers and a char type operator which will signify the operation we want to perform. Also one thing we must note are the use of semi-colons. In coding these
serve almost as periods and signify breaks in line for the computer reading the code.
http://www.instructables.com/id/How-to-Make-a-Simple-Calculator-in-Java/
Step 6: Build our switch statement
For the last portion of the process section, we must make a switch statement. The switch receives the operator variable and depending on what it is, chooses a certain
case.
http://www.instructables.com/id/How-to-Make-a-Simple-Calculator-in-Java/
Step 9: Run our code
Now we can press run and see how well our code performs.
Related Instructables
http://www.instructables.com/id/How-to-Make-a-Simple-Calculator-in-Java/
Advertisements
Comments
1 comments Add Comment
http://www.instructables.com/id/How-to-Make-a-Simple-Calculator-in-Java/