Tuesday, November 23, 2010

Introductory Topics before you start writing Java Codes

2
Different Data Types (most commonly use)

This short topic can give you an idea for different data types that is available to use on either the Java and C++.

a.) double num1 . . .  ;
     use to specify that the variable is a decimal point number. ex. 5.68 
b.) int num1 . . . ;
     use to specify that the variable is an integer. ex 7840 
c.) float num1 . . . ;
     same as double except that this type can handle bigger bits of decimal numbers. ex. 0.903994
d.) String word;
     use to specify that the word is a Character or a String.

Arithmetic Operators
Addition, Subtraction, Multiplication and Division.

Logical Operators

a.) Logical AND (&&)
shows that the two conditions must be satisfied in order to do a command.
Example:


The Console will ask for to enter grade then it will compute for the Grade. Later, It will decide whether the average is less than or equal to 100 and average is greater than or equal to 97.  If it is so, it will display the message "Your Great" otherwise "Better Luck next tym".




b.) Logical OR
shows that either one of the specified conditions must be meet in order to do a command.
Example:
if(x<90 || y=110){
. . . . . . . . . . . . . . . .. . . . ;
}
c.) Logical NOT
shows that if the conditional is not equal to a certain value a command will be executed.
Example:


Ternary Operators
-It uses the symbol (?).  It is a conditional that test if Exp1 is True, then Exp2 will be the value of the given expression.  If Exp1 is False, then Exp3 will be the value of the expression.
General Equation:
Exp1  ?  Exp2 : Exp3
Example

Then it will Output this one.





Incrementation and Decrementation
-It uses the symbol (++/--).  It is an operator that will add a certain value (usually 1).  It is the same as saying x = x +1.  Meaning the previous value of x will be added by 1 everytime it reach a certain condition.  So you must set a condition that will end up the adding process of the variable.
Example


In the created program, the console will keep the displaying the word "Enter grade:" until the counter reach the value of 3 (note that I initialize the value of the counter by 1).  The Program stated that WHILE the counter is less than or equal to 3 (meaning from 1 to 3), the program will keep on displaying the command "Enter Grade".  The Scanner will save the value you entered and do some operations. Finally, the program will display the output. The Console will display this one.



2 Response to Introductory Topics before you start writing Java Codes

December 01, 2010

SUPER HIRAP INTINDIHIN...D BALE ANJAN NAMNA C JOHN PAUL PARA MAGEXPLAIN ii....:":>))

December 26, 2010

dli lang yan..

Post a Comment