L02-Exp-assignment1 - King Fahd University of Petroleum...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
ICS102 Lecture 2: Expressions and Assignment King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science Department
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
December 6, 2010 ICS102: Expressions & Assignment 2 Outline Declaration Statements Primitive Data Types Identifiers Assignment Statements Arithmetic Operators and Expressions Precedence Rules Round-Off Errors in Floating-Point Numbers Integer and Floating-Point Division The  %  Operator Type Casting Increment and Decrement Operators
Background image of page 2
December 6, 2010 ICS102: Expressions & Assignment 3 Variable  In mathematics: x + y = 17 In Computer Science: a variable is an identifier  (usually a letter, word, or phrase) that is linked to  a value stored in the computer's memory x = 5; variable variable variable
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Variable Declaration Every variable in a Java program must be  declared   before it is used int numberOfBeans; numberOfBeans = 10; A variable declaration tells the compiler what kind of data  ( type ) will be stored in the variable Basic types in Java are called  primitive types
Background image of page 4
December 6, 2010 ICS102: Expressions & Assignment 5 - Primitive Data Types
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
December 6, 2010 ICS102: Expressions & Assignment 6 Names of variables (Identifiers) int variable = 3; The name of a variable must not start with a digit, and all the  characters must be letters, digits, or the underscore symbol Java is a case-sensitive language:   Rate rate , and  RATE  are  the names of three different variables It is not allowed to use reserved words as variable names: public class void static
Background image of page 6
December 6, 2010 ICS102: Expressions & Assignment 7 Naming Conventions  (Leave it to the Lab) Start the names of variables, methods, and objects with a  lowercase letter, indicate "word" boundaries with an uppercase  letter, and restrict the remaining characters to digits and  lowercase letters topSpeed bankRate1 timeOfArrival Start the names of classes with an uppercase letter and,  otherwise, adhere to the rules above FirstProgram MyClass String
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
December 6, 2010
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 22

L02-Exp-assignment1 - King Fahd University of Petroleum...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online