Genome Revolution: COMPSCI 006G 2.1 Control in Java and Programming l The computer executes your program one statement at a time, from top to bottom within.

Slides:



Advertisements
Similar presentations
2.1 Program Construction In Java
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.
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
CSC 221: Computer Programming I Fall 2001  conditional repetition  repetition for: simulations, input verification, input sequences, …  while loops.
Chapter 41 Variables and JSP Control Structures JavaServer Pages By Xue Bai.
CS0007: Introduction to Computer Programming
Conditional statements and Boolean expressions. The if-statement in Java (1) The if-statement is a conditional statement The statement is executed only.
Animation Mrs. C. Furman. Animation  We can animate our crab by switching the image between two pictures.  crab.png and crab2.png.
July 13 th.  If/ Else if / Else  Variable Scope  Nested if/else's  Switch statements  Conditional Operator.
5-1 Flow of Control Recitation-01/25/2008  CS 180  Department of Computer Science  Purdue University.
(c) 2003 E.S.Boese1 Conditionals Chapter 10 - Student.
Slides prepared by Rose Williams, Binghamton University Chapter 3 Flow of Control Loops in Java.
CS 106 Introduction to Computer Science I 10 / 04 / 2006 Instructor: Michael Eckmann.
ECE122 L11: For loops and Arrays March 8, 2007 ECE 122 Engineering Problem Solving with Java Lecture 11 For Loops and Arrays.
CSci 142 Data and Expressions. 2  Topics  Strings  Primitive data types  Using variables and constants  Expressions and operator precedence  Data.
Day 4 Objectives Constructors Wrapper Classes Operators Java Control Statements Practice the language.
Genome Revolution: COMPSCI 004G 3.1 What is a program? What is code? l Instructions in a language a computer executes  Languages have different characteristics,
Imperative Programming Part One. 2 Overview Outline the characteristics of imperative languages Discuss other features of imperative languages that are.
CIS Computer Programming Logic
More with Methods (parameters, reference vs. value, array processing) Corresponds with Chapters 5 and 6.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
SINGLE-DIMENSION ARRAYS. Data Structures It is a collection of scalar data types that are all referenced or accessed through one identifier – scalar type.
A Computer Science Tapestry 3.1 Programs that Respond to Input l Programs in chapters one and two generate the same output each time they are executed.
PHP Logic. Review: Variables Variables: a symbol or name that stands for a value – Data types ( Similar to C++ or Java): Int, Float, Boolean, String,
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
CompSci 100E 2.1 Java Basics - Expressions  Literals  A literal is a constant value also called a self-defining term  Possibilities: o Object: null,
COMPUTER PROGRAMMING. Iteration structures (loops) There may be a situation when you need to execute a block of code several number of times. In general,
CSC 107 – Programming For Science. The Week’s Goal.
Introduction to Programming Languages S1.3.1Bina © 1998 Liran & Ofir Introduction to Programming Languages Programming in C.
03 August 2004 NLP-AI Java Lecture No. 4 Operators & Decision Constructs Satish Dethe.
Genome Revolution: COMPSCI 004G 2.1 Bioinformatics Vocabulary l Processing, analyzing, experimenting with data  Where does the data come from?  How do.
February ,  2/16: Exam 1 Makeup Papers Available  2/20: Exam 2 Review Sheet Available in Lecture  2/27: Lab 2 due by 11:59:59pm  3/2:
Other Variable Types Dim lab as String makes a box that can store a label tag Dim ColHead As String ColHead = “function” ColHead function Dim lab as Boolean.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Repetition Control Structure. Introduction Many applications require certain operations to be carried out more than once. Such situations require repetition.
A Computer Science Tapestry 3.1 Tools we have, Tools we need l We know about output  Streams, we’ve seen strings, we’ll see numbers  Streams support.
CPS APTs and structuring data/information l Is an element in an array, Where is an element in an array?  DIY: use a loop  Use Collections, several.
Repetition Statements (Loops). 2 Introduction to Loops We all know that much of the work a computer does is repeated many times. When a program repeats.
CMSC 150 LOOPS CS 150: Fri 20 Jan Representing DNA AGTCCAGTGTCAA.
Chapter 7: Repetition Structure (Loop) Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills.
Control structures in C by Dr P.Padmanabham Professor (CSE)&Director Bharat Institute of Engineering &Technology Hyderabad Mobile
CPS What's in Compsci 100? l Understanding tradeoffs: reasoning, analyzing, describing…  Algorithms  Data Structures  Programming  Design l.
Conditional Statements A conditional statement lets us choose which statement will be executed next Conditional statements give us the power to make basic.
Sections Basic Data Structures. 1.5 Data Structures The way you view and structure the data that your programs manipulate greatly influences your.
CompSci Toward understanding data structures  What can be put in a TreeSet?  What can be sorted?  Where do we find this information?  How do.
if ( condition ) statement; if is a Java reserved word The condition must be a boolean expression. It must evaluate to either true or false.
Java: Base Types All information has a type or class designation
Topics introduced today (these topics would be covered in more detail in later classes) – Primitive Data types Variables Methods “for” loop “if-else” statement.
Identify the Appropriate Method for Handling Repetition
Information and Computer Sciences University of Hawaii, Manoa
Relational Operator and Operations
CS0007: Introduction to Computer Programming
Java: Base Types All information has a type or class designation
Lecture 5: Some more Java!
Multiple variables can be created in one declaration
BY GAWARE S.R. COMPUTER SCI. DEPARTMENT
SSEA Computer Science: CS106A
Control Structures (Structured Programming) for controlling the procedural aspects of programming CS1110 – Kaminski.
LRobot Game.
Variables Numbers can be stored and retrieved while a program is running if they are given a home. The way that integers and decimal numbers are stored.
Chapter 2 Programming Basics.
If-statements & Indefinite Loops
Control Structures (Structured Programming) for controlling the procedural aspects of programming CS1110 – Kaminski.
Java: Variables, Input and Arrays
Comparing Python and Java
Welcome back! October 11, 2018.
Repetition Structures
Java String Class String is a class
What can you put into an ArrayList?
Presentation transcript:

Genome Revolution: COMPSCI 006G 2.1 Control in Java and Programming l The computer executes your program one statement at a time, from top to bottom within the method/function that's called. public int daysIn(int month) { if (month == 1) return 31; if (month == 2) return 28; if (month == 3) return 31; … } l What is the anatomy of a function? Of an if-statement? How do we specify these?

Genome Revolution: COMPSCI 006G 2.2 Lydia Kavraki l Awards  Grace Murray Hopper  Brilliant 10 "I like to work on problems that will generally improve the quality of our life," What's the thing you love most about science? “Working with students and interacting with people from diverse intellectual backgrounds. Discovery and the challenge of solving a tough problem, especially when it can really affect the quality of our lives. I find the whole process energizing.”

Genome Revolution: COMPSCI 006G 2.3 Specifying language constructs public Type Name(parameter-list) { statement-list } parameter-list:: empty-list || non-empty-list non-empty-list:: Type Name non-empty-list:: Type Name, non-empty-list if ( boolean-expression ) { statement-list }

Genome Revolution: COMPSCI 006G 2.4 zero-one, true-false, boolean if ( a == b ) { statement-list } if ( a relational-operator b ) { statement-list } if ( bool-exper conditional bool-expr ) {…} if ( boolean-function ) {…} ==, !=,, = && ||, !

Genome Revolution: COMPSCI 006G 2.5 John Kemeny, ( ) l Invented BASIC, assistant to Einstein, Professor and President of Dartmouth  Popularized computers being ubiquitous on campus/at home  BASIC ported to early personal computers by Gates and Allen l Initially BASIC was free, but many different dialects arose. In 1985 Kemeny and Kurtz shipped TRUE BASIC, to challenge Pascal in academia  What’s used today?

Genome Revolution: COMPSCI 006G 2.6 Equality of values and objects int x = 3*12; if (x == 36) {is-executed} String s = new String("genetic"); String t = s.substring(0,4); if (t == "gene") {not executed} if (t.equals("gene")) {is-executed} l Primitive types are boxes l Object types are labels on boxes  If we don't call new there's no box for the label  No box is called null, it means no object referred to or referenced by variable/pointer/reference

Genome Revolution: COMPSCI 006G 2.7 Objects and values l Primitive variables are boxes  think memory location with value l Object variables are labels that are put on boxes String s = new String("genome"); String t = new String("genome"); if (s == t) {they label the same box} if (s.equals(t)) {contents of boxes the same} s t What's in the boxes? "genome" is in the boxes

Genome Revolution: COMPSCI 006G 2.8 Objects, values, classes l For primitive types: int, char, double, boolean  Variables have names and are themselves boxes (metaphorically)  Two int variables assigned 17 are equal with == l For object types: String, Sequence, others  Variables have names and are labels for boxes  If no box assigned, created, then label applied to null  Can assign label to existing box (via another label)  Can create new box using new l Object types are references or pointers or labels to storage

Genome Revolution: COMPSCI 006G 2.9 Anatomy of for-loop String s = new String("agt"); String rs = new String(""); for(int k=0; k < 3; k++){ rs = rs + s.charAt(k); } l Initialization happens once l Loop test evaluated  If true body executes  If false skip after loop l After loop body, increment executed and test re-evaluated l What should be true about test? l What about body? l What about together?

Genome Revolution: COMPSCI 006G 2.10 Don Knuth (Art of Programming) “My feeling is that when we prepare a program, it can be like composing poetry or music; as Andrei Ershov has said, programming can give us both intellectual and emotional satisfaction, because it is a real achievement to master complexity and to establish a system of consistent rules.” “We have seen that computer programming is an art, because it applies accumulated knowledge to the world, because it requires skill and ingenuity, and especially because it produces objects of beauty.”