CIS 110: Introduction to Computer Programming

Slides:



Advertisements
Similar presentations
Chapter 1: Computer Systems
Advertisements

INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
JAVA BASICS SYNTAX, ERRORS, AND DEBUGGING. OBJECTIVES FOR THIS UNIT Upon completion of this unit, you should be able to: Explain the Java virtual machine.
JAVA BASICS SYNTAX, ERRORS, AND DEBUGGING. GCOC – A.P. Computer Science A College Board Computer Science A Topics Covered Program Design - Read and understand.
Copyright 2008 by Pearson Education Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading: self-check: #1-14.
©2004 Brooks/Cole Chapter 1: Getting Started Sections Covered: 1.1Introduction to Programming 1.2Constructing a Java Program 1.3The print() and println()
Slide 1 of 40. Lecture A The Java Programming Language Invented 1995 by James Gosling at Sun Microsystems. Based on previous languages: C, C++, Objective-C,
Copyright 2006 by Pearson Education 1 Building Java Programs Chapter 1: Introduction to Java Programming.
Copyright 2013 by Pearson Education Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
1 Building Java Programs Chapter 1: Introduction to Java Programming These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may.
Copyright 2008 by Pearson Education Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading: self-check: #1-14.
“Introduction to Programming With Java”
Chapter 1 Introduction.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
CS 106 Introduction to Computer Science I 01 / 25 / 2010 Instructor: Michael Eckmann.
Introduction to Java Thanks to Dan Lunney (SHS). Java Basics File names The “main” method Output to screen Escape Sequence – Special Characters format()
Chapter 1 CSIS-120: Java Intro. What is Programming?  A: It is what makes computer so useful.  The flexibility of a computer is amazing  Write a term.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
JAVA BASICS: Variables and References SYNTAX, ERRORS, AND DEBUGGING.
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Week 1 - Friday.  What did we talk about last time?  Our first Java program.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Guide to Programming with Python Chapter One Getting Started: The Game Over Program.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Output in Java Hello World!. Structure of a Java Program  All Java files in ICS3U1 have the following structure: class HelloWorld { }  Notice the open.
CSC 1051 – Algorithms and Data Structures I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Introduction to programming in the Java programming language.
© 2004 Pearson Addison-Wesley. All rights reserved ComS 207: Programming I Instructor: Alexander Stoytchev
1 WELCOME TO CIS 1068! Instructor: Alexander Yates.
CS 106 Introduction to Computer Science I 01 / 22 / 2007 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 01 / 22 / 2008 Instructor: Michael Eckmann.
CS 177 Recitation Week 1 – Intro to Java. Questions?
ITP 109 Week 2 Trina Gregory Introduction to Java.
CS 106 Introduction to Computer Science I 01 / 24 / 2007 Instructor: Michael Eckmann.
Chapter 3 Introducing Java. Objectives and Goals 1. Define terminology associated with object- oriented programming. 2. Explain why Java is a widely used.
Copyright 2010 by Pearson Education CSE 142, Spring 2012 Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading: 1.1 -
Welcome to CSE 142! Zorah Fung University of Washington, Summer Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs.
Copyright 2010 by Pearson Education APCS Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana Pronounced Bah-bah Co-fee Way-ou-see-jah-nah Call him “Baba” or “Dr. Weusijana”
Introduction to Object Oriented
Zorah Fung University of Washington, Winter 2016
Introduction to programming in java
C++ First Steps.
Chapter 1 – Introduction
Lecture 1: Introduction; Basic Python Programs
CS170 – Week 1 Lecture 3: Foundation Ismail abumuhfouz.
Chapter 3 GC 101 Java Fundamentals.
Console Output, Variables, Literals, and Introduction to Type
Principles of Programming I (CIE 105)
Introduction to.
CSE 190D, Winter 2013 Building Java Programs Chapter 1
Data types and variables
String Output ICS 111: Introduction to Computer Science I
Chapter 1: Computer Systems
Fundamentals of Programming
Benson Limketkai University of Washington, Spring 2011
Building Java Programs
Advanced Programming CS206
Building Java Programs
Welcome to CSE 142!.
CSE 142, Summer 2012 Building Java Programs Chapter 1
ICT Gaming Lesson 2.
CSE 142, Spring 2012 Building Java Programs Chapter 1
Zorah Fung University of Washington, Spring 2015
CSE 142, Winter 2014 Building Java Programs Chapter 1
Instructor: Alexander Stoytchev
Zorah Fung University of Washington, Winter 2016
CSC 241: Introduction to Computer Science I
How to Run a Java Program
Presentation transcript:

CIS 110: Introduction to Computer Programming Lecture 1 An introduction of an introduction (§ 1.1 – 1.3)* *(no, you shouldn’t have read those yet =P)

What is computer programming? What is computer science? (By demonstration!) 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

What is Computer Science? “Computer programming is not computer science” Programming languages Computer security and privacy Software engineering Databases and data management Artificial intelligence/machine learning Operating systems and networking Graphics Mobile, distributed, and ubiquitous systems Computer architecture Compilers Computational biology Embedded and real-time systems Algorithms and complexity analysis Formal methods Human-computer interaction Theory of computation What unifies all these crazy, different things? 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

CIS 110 (11fa) - University of Pennsylvania Algorithmic Thinking Algorithm: a step-by-step procedure to solve a problem Algorithmic thinking: a structured approach to problem solving It represents a universally applicable attitude and skill set everyone, not just computer scientists, would be eager to learn and use. - Jeannette M. Wing (CMU professor) 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

The Three Skills of Algorithmic Thinking Precision “Accurately and completely describe how to solve a problem” Decomposition “Break up a big problem into smaller ones.” Abstraction “Recognize that several problems are the same.” 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

How are CS and Programming Related? It has often been said that a person does not really understand something until after teaching it to someone else. Actually a person does not really understand something until after teaching it to a computer, i.e., expressing it as an algorithm. - Donald Knuth 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

What is Computer Programming? Two things for our purposes: A way to practice algorithmic thinking skills in a concrete way A practical skill you can use in your own job While computer programming is not computer science, programming allows us to exercise the core skills that all computer scientists possess. Also, sharpening our algorithmic thinking makes us better programmers! 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

CIS 110 (11fa) - University of Pennsylvania Logistics 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

CIS 110 (11fa) - University of Pennsylvania About me My name: Peter-Michael Osera. Call me whatever you want, e.g., Peter Michael Mikey Pete-Moss Pete Mike PM (Lots more, many inappropriate) I am a 4th year Ph.D. student (not a professor). Programming languages researcher. Former program manager @ Microsoft (VC++ compiler). Die-hard supporter of e-sports and pro-gaming. 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

CIS 110: the Highlights See the syllabus for more details 2 lecture offerings (11-12 and 1-2) Required lab section (10% of your grade) Required textbook: Building Java Programs: A Back to Basics Approach, Reges and Stepp Piazza message board system No curve, slide if necessary Late day policy (4 late days) 2 exams, 1 final See the syllabus for more details 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

CIS 110 vs. CIS 120 To swap classes, please speak to your instructor. CIS 110 and 120 = the CS intro sequence. Both emphasize algorithmic thinking via programming. CIS 110: Assumes no prior programming experience. Focuses on control issues in programming. Uses the Java programming language. CIS 120: Assumes prior programming experience. Focuses on data representation issues in programming. Initially uses OCaml then goes back to Java. To swap classes, please speak to your instructor. 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

CIS 110 (11fa) - University of Pennsylvania Computer Programming 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

What is a Computer Program? Imagine that we need to tell our best friend to do something, but he doesn’t speak our language. PUT THE JELLY ON THE BREAD THEN PUT IT ALL IN YOUR MOUTH ???? 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

CIS 110 (11fa) - University of Pennsylvania Translation We can translate our instructions so that our best friend understands them. PUT THE JELLY ON THE BREAD AND THEN PUT IT ALL IN YOUR MOUTH Ilagay ang halaya SA tinapay AT pagkatapos ay ilagay ito LAHAT SA INYONG bibig 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

CIS 110 (11fa) - University of Pennsylvania The analogy revealed The compiler You (the programmer) The computer (your new best friend) PUT THE JELLY ON THE BREAD AND THEN PUT IT ALL IN YOUR MOUTH Ilagay ang halaya SA tinapay AT pagkatapos ay ilagay ito LAHAT SA INYONG bibig The computer program Machine code 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

Programming Languages Natural languages (e.g., English) are Ambiguous. Overly general. Difficult to translate (in fact, a big research field!). Solution: create specialized programming languages that are good at specifying instructions to computers. Examples: Ada, Algol, BASIC, C, C++, C#, CLOS, D, Eiffel, Fortran, F#, Haskell, and so many more! 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

The Java Programming Language Created in 1990 by Sun Microsystems Alternative to C/C++ Object-oriented language “(Almost) Everything is an object” Platform independent Java programs run on Windows, Mac, or Linux Most popular language out there See the TIOBE programming index 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

Our first computer program. (jGRASP demonstration) 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

The Compilation Pipeline (In jGRASP) [Step 2: compile the source code] [Step 1: write source code] (Output: Java bytecodes) 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

Running your compiled program Step 3: tell the computer to run your program (In jGRASP) 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

The structure of a Java Program A class named HelloWorld. For now, classes are containers for our programs. public class HelloWorld { public static void main(String[] args) { System.out.println(“Hello World”!); } A method named main. main is a special method because this is where the program begins execution. A statement that prints “Hello World” to the console. Statements are commands to be executed by your program. 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

CIS 110 (11fa) - University of Pennsylvania Syntax, syntax, syntax Syntax: the rules to form legal programs Class template public class <name> { <method> … } Method template public static void <name>(…) { <statement> ; … } 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

Syntax errors Syntax errors occur when you violate a syntax rule. 1 public class HelloWorld { 2 public static void main(String[] args) { 3 System.out.println("Hello World!"); 4 System.out.println() 5 System.out.println("I like pie"); 6 System.out.println("I like pie a lot"); 7 } 8 } Line numbers. Not part of the program. Need to fix syntax errors before your program can be compiled! 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

Naming and Identifiers In Java, names have several restrictions. Must not be a reserved keyword (e.g., public, class). Many others, see page 20 of the text for the complete list. Must start with a letter, _ (underscore), or $. Otherwise can contain, letters, numbers, _, or $. E.g., HelloWorld42 is valid, 12HelloWorld is not. Java is a case-sensitive language. E.g., main and Main are different names. The name of a class must match its containing Java file E.g., the HelloWorld class is found in HelloWorld.java 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

CIS 110 (11fa) - University of Pennsylvania System.out.println Prints to the screen or console. How to pronounce it: print-lin Two uses: System.out.println(“msg”) prints msg to the screen along with a newline. System.out.println() prints a newline. 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

CIS 110 (11fa) - University of Pennsylvania Strings A string is a piece of data that represents text. E.g., to be println’ed to the console. Syntax: “text goes here” Text surrounded by quotes. Restrictions: Cannot span over multiple lines “this is a syntax error!” Cannot contain a quotation mark “when does this string begin” and end?” 1/1/2019 CIS 110 (11fa) - University of Pennsylvania

CIS 110 (11fa) - University of Pennsylvania Escape sequences Escape sequences allow us to write special characters in strings. Quotation mark: \” Tab character: \t Newline character: \n Backslash: \\ Ex: System.out.println(“\\\\\”\”\”\”\\”); prints \\””””\ to the console! 1/1/2019 CIS 110 (11fa) - University of Pennsylvania