OPERATOR Dalam Java.

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Repetition Statements Perform the same task repeatedly Allow the computer to do the tedious, boring things.
Introduction to Programming
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Java Planning our Programs Flowcharts Arithmetic Operators.
IntroductionIntroduction  Computer program: an ordered sequence of statements whose objective is to accomplish a task.  Programming: process of planning.
10-Jun-15 Just Enough Java. Variables A variable is a “box” that holds data Every variable has a name Examples: name, age, address, isMarried Variables.
Variables Pepper. Variable A variable –box –holds a certain type of value –value inside the box can change Example –A = 2B+1 –Slope = change in y / change.
1 Fundamental Data types Overview l Primitive Data Types l Variable declaration l Arithmetical Operations l Expressions l Assignment statement l Increment.
Chapter 2: Java Fundamentals Operators. Introduction to OOP Dr. S. GANNOUNI & Dr. A. TOUIR Page 2 Content Group of Operators Arithmetic Operators Assignment.
1 Data types, operations, and expressions Overview l Primitive Data Types l Variable declaration l Arithmetical Operations l Expressions.
Aalborg Media Lab 21-Jun-15 Software Design Lecture 2 “ Data and Expressions”
Program Elements We can now examine the core elements of programming (as implemented in Java) We focuse on: data types variable declaration and use, constants.
Fundamental Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
Primitive Types CSE 115 Spring 2006 April 3 &
Addition & Subtraction Add Plus More than Subtract Difference Take away Altogether Minus Less than +-
Shorthand operators.
01- Intro-Java-part1 1 Introduction to Java, and DrJava Barb Ericson Georgia Institute of Technology June 2008.
Exercises A-Declare a variable of double type with initial value=0.0; B- Declare a constant of String type with initial value=“Good” C- Declare a variable.
Computer Science Selection Structures.
LESSON 6 – Arithmetic Operators
Java Keywords  Reserved Words Part of the Java language Examples: public, static, void  Pre-defined Java Identifiers Defined in Java Libraries Examples:
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
 JAVA Compilation and Interpretation  JAVA Platform Independence  Building First JAVA Program  Escapes Sequences  Display text with printf  Data.
BUILDING JAVA PROGRAMS CHAPTER 2 PRIMITIVE DATA TYPES AND OPERATIONS.
Boolean expressions, part 2: Logical operators. Previously discussed Recall that there are 2 types of operators that return a boolean result (true or.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 2: Variables & Data Types.
Evaluating a Variable Expression To evaluate a variable expression:
Java operatoriai sandbolts/operators.html
Divide. Evaluate power – 3 = – 3 EXAMPLE – 3 = 3 2 – – 3 = 6 – 3 Multiply. Evaluate expressions Multiply and divide from.
PHY-102 SAPVariables and OperatorsSlide 1 Variables and Operators In this section we will learn how about variables in Java and basic operations one can.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Operators in JAVA. Operator An operator is a symbol that operates on one or more arguments to produce a result. Java provides a rich set of operators.
Programs That Calculate. Arithmetic Expressions +addition -subtruction *multiplication /division  Order of Operations BEDMAS (brackets, exponentiation,
CSM-Java Programming-I Spring,2005 Fundamental Data Types Lesson - 2.
A: A: double “4” A: “34” 4.
Boolean expressions, part 1: Compare operators. Compare operators Compare operators compare 2 numerical values and return a Boolean (logical) value A.
Operators.
I’m Thinking of a Number
© 2007 Pearson Addison-Wesley. All rights reserved2-1 Character Strings A string of characters can be represented as a string literal by putting double.
1 CS161 Introduction to Computer Science Topic #6.
Expressions and Order of Operations Operators – There are the standard operators: add, subtract, divide, multiply – Note that * means multiply? (No times.
Expression and Operator. Expressions and Operators u Examples: 3 + 5; x; x=0; x=x+1; printf("%d",x); u Two types: –Function calls –The expressions formed.
Programming Fundamentals. Summary of Previous Lectures Phases of C++ Environment Data Types cin and cout.
Operators A binary operator combines two values to get one result: x OP y where OP is any binary operators such as +, -, *, /, ==, !=, >, &&, or even =.
Inside Class Methods Chapter 4. 4 What are variables? Variables store values within methods and may change value as the method processes data.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
CompSci 230 S Programming Techniques
Lecture 3 Java Operators.
Multiple variables can be created in one declaration
Primitive Data, Variables, Loops (Maybe)
Java operatoriai
By: Muhammad Zidny Naf’an
Operators and Expressions
Review Operation Bingo
Computing Adjusted Quiz Total Score
Problem-Solving Steps Solve Problem-Solving Steps Solve
OPERATORS (2) CSC 111.
.Net Programming with C#
Divide the number in C by 10.
Algorithms computer as the tool process – algorithm
Chapter 2: Java Fundamentals
Fractions Mixed Numbers
Operators In Java Programming By Rajanikanth B.
In this class, we will cover:
Just Enough Java 17-May-19.
Fractions V Mixed Numbers
COMPUTING.
Presentation transcript:

OPERATOR Dalam Java

Computes the remainder of dividing op1 by op2 Operator Aritmatika Operator Use Description + op1 + op2 Adds op1 and op2 * op1 *op2 Multiplies op1 by op2 / op1 / op2 Divides op1 by op2 % op1 % op2 Computes the remainder of dividing op1 by op2 - op1 - op2 Subtracts op2 from op1

Operator Increment dan Decrement Use Description ++ op++ Increments op by 1; evaluates to the value of op before it was incremented ++op Increments op by 1; evaluates to the value of op after it was incremented -- op-- Decrements op by 1; evaluates to the value of op before it was decremented --op Decrements op by 1; evaluates to the value of op after it was decremented

Contoh int i = 10, int j = 3; int k = 0; k = ++j + i; // menghasilkan k = 4+10 = 14 k = --j + i; //menghasilkan k = 2+10 = 12 k = j++ + i; // menghasilkan k = 3+10 = 13 k = j-- + i; //menghasilkan k = 3+10 = 13

op1 is greater than or equal to op2 op1 is less than or equal to op2 Operator Relasi Operator Use Description > op1 > op2 op1 is greater than op2 >= op1 >= op2 op1 is greater than or equal to op2 < op1 < op2 op1 is less than op2 <= op1 <= op2 op1 is less than or equal to op2 == op1 == op2 op1 and op2 are equal != op1 != op2 op1 and op2 are not equal

&& (logika AND) dan & (boolean logika AND) x1 x2 Result TRUE FALSE

|| (logika OR) | (boolean logika inclusive OR) x1 x2 Result TRUE FALSE

^ (boolean logika ExclusiveOR ) Result TRUE FALSE

! (logika NOT) x1 Result TRUE FALSE

Operator Kondisi(?:) Struktur pernyataan yang menggunakan operator kondisi adalah, exp1 ? exp2 : exp3

Contoh class kondisiOperator { public static void main( String[] args ){ int score = 0; char answer = 'a'; score = (answer == 'a') ? 10 : 0; System.out.println("Score = " + score ); }

Terima Kasih …. Next Structure …