Tuesday, 27 October 2015
Java | Reading Input From The Computer Console
I can see us progressing well. Can't you? Yes You Can. lol
When I say reading input from the computer console. What do I mean?
I mean trying to tell the computer to give me a chance to give it a value which it would take do some computations and give me the output.
WOW! That sound's cool right? YES!
In order for a computer console to give you a chance to give it a value there is something you must really really know and that thing is called SCANNER.
Yes! Scanner
Do you still remember specific import I talked about in one of my previous posts?
If you don't please review that post. It would enhance your understanding of what we are about to do here a little bit, OK?
For us to send data to the computer there is something we must import into our program.and this Java statement is written right under the package statement OK?
This statement is:
Constants, Computation of Formulas and Concatenation in Java
You and I are Awesome!!!
I want to point out somethings with regards to my previous post which are:
1. Variables have a naming convention that is to say you cannot name a variable anyhow you want. To name a variable the first letter should begin with a small letter and the next word should begin with a capslock for example: averageClass is correct. Averageclass is wrong, averageclass is wrong, AverageClass is wrong for naming a variable but correct for naming a class.
2. The computer does not see mathematical calculations exactly the way we see it.
For example: Mathematically, 5 / 2 = 2.5
But in programming, 5 / 2 = 2
The reason is this, the computer sees the numerator and the denominator as integers (numbers that do not have a fraction or decimal point). Therefore, the computer gives its answer as an integer too and not a floating point number.
To tackle this problem, you have to make the computer see either the numerator or the denominator as a floating point number so that your answer can also be a floating point number.
For Example: In programming, 5.0 / 2 = 2.5 or 5 / 2.0 = 2.5
Another way to solve this problem is through declaration and initialization. See this chunk of code as an example:
Monday, 26 October 2015
Java Variables, DataTypes, Declaration and Initialization
Before I begin this post I need to tell you that Java was invented by a man named James Gosling.
That's all.
Now I begin
In the previous post we talked about expressions and how they can be computed using Java programming language.
Now I want to discuss how to use variables.
Before I show you how to make use of variables, here is a very important point you should know.
Java Expression Computation
Wow! We are becoming Java programmers gradually for reals.
Now I want to teach you something nice and that nice thing is called an operation or expression.
For one to refer to a chunk of code as an expression, two things must be involved:
1. Operator
2. Operand
Mathematically, an expression is something like 4 x 5 etc.
In the above example:
4 and 5 are known as operands while x is known as an operator and putting them together the way they are in the example makes it an expression.
This same thing goes for programming. Just like 4 x 5 as used in the example as a mathematical expression. It can also be a programming expression.
There are five major operators used in Java programming that I want to talk about today which are:
Welcome To Java
As I said earlier, Java is a platform independent programming language that can also be embedded into HTML pages.
All Java source files ends with .java extension which means that if you want to save a file written in java programming language to be run by the computer, you should save with .java. For Example: helloworld.java, welcome.java, computearea.java
This may be a little bit confusing for you now but with time you would understand everything. Every class is compiled into a separate bytecode file that has the same name as the class and ends with the .class extension.
Since we are making use of NetBeans IDE you would probably have nothing to do with files with .class extension so for now so let's keep going.
Set Up NetBeans Integrated Development Environment
After you have installed NetBeans IDE, this is a screenshot of what you might be seeing especially for NetBeans 7.3 below
Sunday, 25 October 2015
Full Tutorials On How To Program: Java
Java is a widely used programming language that has a vast range of applications.
Java can be used to code internet applications, desktop applications and software for embedded systems or devices.
Before I commence with my introduction I would like to make known some points.
if you are reading this post I am sure you know what a computer is or should I start explaining? The answer is NO.
If you do not know what a computer is i don't know what to tell you. lol.
Ok that said do you know that a computer is a hardware? The answer is YES. Why am I even asking this stupid questions? I don't know
With that said I have another question do you know that a computer is nothing without a software?
The answer is hmmm... YES.
Subscribe to:
Posts (Atom)