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

Info icon This 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
Image of page 1

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

View Full Document Right 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
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
Image of page 3

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

View Full Document Right 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
Image of page 4
December 6, 2010 ICS102: Expressions & Assignment 5 - Primitive Data Types
Image of page 5

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

View Full Document Right 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
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
Image of page 7

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

View Full Document Right Arrow Icon
December 6, 2010 ICS102: Expressions & Assignment
Image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern