Introduction to Computer Programming

Slides:



Advertisements
Similar presentations
© 2007 Lawrenceville Press Slide 1 Assignment Statement An assignment statement gives a value to a variable. Assignment can take several forms: x = 5;
Advertisements

Chapter 2 Review Questions
Primitive Data Types There are a number of common objects we encounter and are treated specially by almost any programming language These are called basic.
Data Types in Java Data is the information that a program has to work with. Data is of different types. The type of a piece of data tells Java what can.
Introduction to Computers and Programming Lecture 4: Mathematical Operators New York University.
Mathematical Operators: working with floating point numbers and more operators  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this.
CS 1 with Robots Variables, Data Types & Math Institute for Personal Robots in Education (IPRE)‏
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie June 27, 2005.
Copyright 2008 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
Chapter 4 Variables and Constants. Goals and Objectives 1. Understand simple data types (int, boolean, double). 2. Declare and initialize variables using.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Week 10 Steve Jobs Steven Paul Jobs (February 24, 1955 – October 5, 2011) was an American businessman and inventor widely recognized as a charismatic pioneer.
CHAPTER 4: CONTROL STRUCTURES - SEQUENCING 10/14/2014 PROBLEM SOLVING & ALGORITHM (DCT 1123)
Building Java Programs Primitive Data and Definite Loops.
Code Grammar. Syntax A set of rules that defines the combination of symbols and expressions.
Introduction to Computer Programming CS 126 Lecture 4 Zeke Maier.
Copyright 2008 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Programming in Java (COP 2250) Lecture 4 Chengyong Yang Fall, 2005.
Copyright 2010 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 2A Reading, Processing and Displaying Data (Concepts)
1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
 Variables can store data of different types, and different data types can do different things.  PHP supports the following data types:  String  Integer.
Variables and Constants Chapter 4 Review. Declaring Variables A variable is a name for a value stored in memory. Variables and constants are used in programs.
Inside Class Methods Chapter 4. 4 What are variables? Variables store values within methods and may change value as the method processes data.
Copyright 2010 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
© 2004 Pearson Addison-Wesley. All rights reserved August 27, 2007 Primitive Data Types ComS 207: Programming I (in Java) Iowa State University, FALL 2007.
CompSci 230 S Programming Techniques
Fundamentals of Programming I Overview of Programming
Chapter 2 Variables.
Chapter 4 Assignment Statement
Lecture 2: Static Methods Expressions reading: 1.4 – 2.1
Building Java Programs
Primitive Data Types August 28, 2006 ComS 207: Programming I (in Java)
Lecture 2: Data Types, Variables, Operators, and Expressions
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
Multiple variables can be created in one declaration
Chapter 3 Assignment Statement
Type Conversion, Constants, and the String Object
Introduction to Computer Programming
Building Java Programs Chapter 2
Introduction to C++ Programming
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs Chapter 2
elementary programming
Lecture 2: Static Methods Expressions reading: 1.4 – 2.1
Building Java Programs
Apple and Steve Jobs Prof. Arjun B. Bhagwat Department of Commerce
Chapter 2 Programming Basics.
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs Chapter 2
Building Java Programs
Chapter 2 Variables.
Building Java Programs
Building Java Programs
Lecture 9: JavaScript Syntax
Building Java Programs
Primitive Data Types and Operators
Introduction to Python
Building Java Programs
Presentation transcript:

Introduction to Computer Programming CS 126 Lecture 3 Zeke Maier

Plan for Today Questions Administrivia Data Types and Expressions Assignment

Questions Steve Jobs Products? Macworld Health? iPod iPhone iTunes MacBook Macworld iTunes Store selling DRM free music Weight Loss, Hormone Imbalance, More Complex…, 6 month leave of absence, Cancer? Steven Paul Jobs 1955, is the American co-founder, Chairman, and CEO of Apple Inc. and the former CEO of Pixar Animation Studios. In the late 1970s, Jobs, with Apple co-founder Steve Wozniak, created one of the first commercially successful personal computers. In the early 1980s, Jobs was among the first to see the commercial potential of the mouse-driven graphical user interface Jobs's history in business has contributed greatly to the myths of the quirky, individualistic Silicon Valley entrepreneur, emphasizing the importance of design while understanding the crucial role aesthetics play in public appeal. His work driving forward the development of products that are both functional and elegant has earned him a devoted following.[12] Jobs is currently on a leave of absence from Apple due to health issues.[13 is considered one of Silicon Valley's leading egomaniacs. Jobs has always aspired to position Apple and its products at the forefront of the information technology industry by foreseeing and setting trends, at least in terms of innovation and style. Digital Rights Management (DRM)-free. End of march Other musinc playing devices (Zune) can play music bought from the iTunes Store (codecs on song required it to be played by a Mac product) DRM (restrcit copying and other illeagal activities)

Administrivia http://students.cec.wustl.edu/~ejm3/ TAs! CEC accounts Lab assignments Readings

Data Types Everything in Java has a type Primitive Types type: “kind of thing” Primitive Types int: Integer number: 5, 10, 15 double: Decimal number: 5.15, 10.25 boolean: true or false String: a string of characters: “Hello World”

Expressions Expression: anything that has a value Order of operations infix expression syntax operators between operands Order of operations Evaluate left to right under the rules Negation (-) Multiplication(*), Division(/), & Modulus(%) Addition(+), Subtraction(-)

Expression Trees Evaluated left to right and bottom to top * + % 8 5 18 5

String Concatenation Boolean Expressions + operator will combine strings together Other primitive values will be converted to strings when concatenation occurs Boolean Expressions Expressions that evaluate to true or false && and operator || or operator ! not operator == equals operator

Variables A symbol which can hold a value of a particular type int age; String myName; double cars; Assign a value of a variable int age = 24; String myName = “Zeke”; double cars = 0.5; Think of a variable as a container with the "right shape" to hold a value of the declared type Assign the value of an expression to a variable double money = 45.50 - (3 * 1.50);

Assigning New Values Variables can be reassigned a new value int age = 24; age = 25; int age = 24; age = age + 1; final keyword forces variable to retain initial value final variables, called constants, have all uppercase names final int AGE = 24; AGE = 25; //Error

Composition Combining small blocks of code How could we compose these three statements into a single statement? int age; age = 24; System.out.print(age);

Naming Abstraction Circle Area Example Giving names to values: using variables What are some advantages? Choose meaningful names for variables! Circle Area Example It saves us from retyping the value all the time and makes programs easier to read.

Assignment No Class Monday Readings Wednesday AD Chapter 2, Chapter 7: 7.8 - 7.10 KG Notes