Programming Environments

Slides:



Advertisements
Similar presentations
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.
Advertisements

STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
IntroductionIntroduction  Computer program: an ordered sequence of statements whose objective is to accomplish a task.  Programming: process of planning.
©2004 Brooks/Cole Chapter 2 Variables, Values and Operations.
Programming Environments DrJava is not Java! It is an integrated environment for developing Java programs DrJava integrates the Edit => Compile => Run.
Hello, world! Dissect HelloWorld.java Compile it Run it.
01- Intro-Java-part1 1 Introduction to Java, and DrJava Barb Ericson Georgia Institute of Technology June 2008.
Introduction to Python
Georgia Institute of Technology Introduction to Java, and DrJava Barb Ericson Georgia Institute of Technology Aug 2005.
Lecture 2 Object Oriented Programming Basics of Java Language MBY.
Java means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
Basics of Java IMPORTANT: Read Chap 1-6 of How to think like a… Lecture 3.
Operators in Python. Arithmetic operators Some operators in Python will look familiar (+, -, *, /) Others are new to you (%, //, **) All of these do work.
 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.
Copyright 2008 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
Mixing integer and floating point numbers in an arithmetic operation.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
Final Jeopardy Fundamen tal Java Numerical Data type Boolean Expressi on If/THEN/ WHILE Miscellan eous
Copyright 2010 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
Data Tonga Institute of Higher Education. Variables Programs need to remember values.  Example: A program that keeps track of sales needs to remember.
Boolean expressions, part 1: Compare operators. Compare operators Compare operators compare 2 numerical values and return a Boolean (logical) value A.
Topic 4 Expressions and variables Based on slides bu Marty Stepp and Stuart Reges from "Once a person has understood.
COP 2551 Introduction to Object Oriented Programming with Java Topics –Introduction to the Java language –Code Commenting –Java Program Structure –Identifiers.
Primitive Data Types. int This is the type you are familiar with and have been using Stores an integer value (whole number) between -2,147,483,648 (-2.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
Georgia Institute of Technology Introduction to Java, and DrJava part 1 Dr Usman Saeed Assistant Professor Faculty of Computing and Information Technology.
CPSC 233 Tutorial January 21 st /22 nd, Linux Commands.
Information and Computer Sciences University of Hawaii, Manoa
Basic concepts of C++ Presented by Prof. Satyajit De
Chapter 2 Variables.
Lecture 2 D&D Chapter 2 & Intro to Eclipse IDE Date.
Chapter 2 Basic Computation
Building Java Programs
Primitive Data, Variables, Loops (Maybe)
Java package classes Java package classes.
Computer Programming Methodology Introduction to Java
Programming Environments
Building Java Programs Chapter 2
Principles of Computer Programming (using Java) Chapter 2, Part 1
Unit-2 Objects and Classes
An Introduction to Java – Part I, language basics
Introduction to Java, and DrJava part 1
Building Java Programs
Building Java Programs
Chapter 2 Variables.
Sridhar Narayan Java Basics Sridhar Narayan
Building Java Programs
Building Java Programs Chapter 2
Introduction to Java, and DrJava
Building Java Programs
Java Programming Review 1
Chapter 2 Programming Basics.
Building Java Programs
Building Java Programs
Building Java Programs
Introduction to Primitives
Introduction to Primitives
Java Programming with BlueJ Objectives
Building Java Programs
Building Java Programs Chapter 2
Introduction to Java, and DrJava
Introduction to Java, and DrJava part 1
Chapter 2 Variables.
Just Enough Java 17-May-19.
Agenda Packages and classes Types and identifiers Operators
Building Java Programs
Presentation transcript:

Programming Environments DrJava is not Java! It is an integrated environment for developing Java programs DrJava integrates the Edit => Compile => Run cycle Other: jGrasp, BlueJ, Eclipse IDLE is not Python! It is an integrated environment for developing Python programs IDLE integrates the Edit => Run cycle Other: DrPython, PyScripter, Eclipse

Java Program Development Cycle Edit => Compile => Run Edit: create Program.java Compile: create Program.class javac Program.java Run java Program Program.java – human readable Program.class – machine readable

Compiled vs Interpreted Language Compiled – whole program is translated before it can be run; once compiled can run many times Ensures that the whole program obeys language rules Analogy: Translating a book before it can be mass printed Interpreted – only the line currently executing is translated; re-translated every time the program is run Allows for immediate feedback, faster development cycle Analogy: Translator for a guest speaker

Java Primitive Types boolean – for true/false values char – for single character values short, int, long – for integer values short [ -32,768 … 32,767 ] int [ -2,147,483,648 … 2,147,483,647 ] long [ -9,223,372,036,854,775,808 … 9,223,372,036,854,775,807 ] float, double – for real values float has smaller range than double

In how many ways can you say X = X + 1 ? X = X – 1; X = X * 5; X = X / 5; X -= 1; X *= 5; X /= 5; X--; --X;

X++ vs ++X X = 5; X = 5; Y = X++; Y = ++X; Y is now 5 X is now 6 2: update the value of X 1: update the value of X Y = X++; Y = ++X; 1: “use” the value of X 2: “use” the value of X Y is now 5 X is now 6 X is now 6 Y is also 6

System.out.println(X++); System.out.println(++X); X++ vs ++X X = 5; X = 5; 2: update X 1: update X System.out.println(X++); System.out.println(++X); 1: “use” the value of X 2: “use” the value of X displays 5 X is now 6 X is now 6 displays 6

Integer Division Dividing integers always yields integer value 7 / 3 = 2 int x = 7; int y = 3; int z1 = x / y; // z1 is now 2 double z2 = x / y; // z2 is now 2 Remainder operator % 7 / 3 = 2 and 1 left over, so 7 % 3 = 1 9 / 5 = 1 and 4 left over, so 9 % 5 = 4 21 / 5 = 4 and 1 left over, so 21 % 5 = 1

Remainder % Operator Use if ( n % 2 == 0 ) { System.out.println( “n is even “ ); } if ( n % 5 == 0 ) System.out.println( “n is divisible by 5 “ ); player = ( player + 1 ) % n;

do-while loop while ( something-is-true ) { action 1; action 2; ... action n } do-while guaranteed to execute at least once do { action 1; action 2; ... action n } while ( something-is-true )

Return in void Methods void drawCirclesRow( double x, double y, double r, int n) { if (n <= 0) return; // OK without value } ... rest of the code here ...

Enhanced FOR Loop

Enhanced FOR Loop

Enhanced FOR Loop

In Python