CS 106 Introduction to Computer Science I 01 / 25 / 2010 Instructor: Michael Eckmann.

Slides:



Advertisements
Similar presentations
Programming for Beginners
Advertisements

CS 102 Computers In Context (Multimedia) 01 / 21 / 2009 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 01 / 20 / 2009 Instructor: Michael Eckmann.
CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
C Introduction Lesson CS1313 Spring C Introduction Lesson Outline 1.C Introduction Lesson Outline 2. hello_world.c 3.C Character Set 4.C is Case.
 2005 Pearson Education, Inc. All rights reserved Introduction.
C Introduction Lesson CS1313 Spring C Introduction Lesson Outline 1.C Introduction Lesson Outline 2. hello_world.c 3.C Character Set 4.C is Case.
Chapter 1: Introduction
Chapter 2: Your First Program! Hello World: Let’s Program  All programs must have the extension.java  Our first program will be named: HelloWorld.java.
Chapter 1 These slides for CSE 110 Sections are based in part on the textbook-authors’ slides, which are copyright by the authors. The authors state that.
CS 206 Introduction to Computer Science II 09 / 09 / 2009 Instructor: Michael Eckmann.
INTRODUCTION T.Najah Al_Subaie Kingdom of Saudi Arabia Prince Norah bint Abdul Rahman University College of Computer Since and Information System CS240.
Week 1 - Wednesday.  What did we talk about last time?  Syllabus  Computers.
Introduction To Computers and Programming Lecture 2: Your first program Professor: Evan Korth New York University.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
CS 330 Programming Languages 09 / 07 / 2006 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 02 / 12 / 2007 Instructor: Michael Eckmann.
©2004 Brooks/Cole Chapter 1: Getting Started Sections Covered: 1.1Introduction to Programming 1.2Constructing a Java Program 1.3The print() and println()
CS 206 Introduction to Computer Science II 09 / 03 / 2008 Instructor: Michael Eckmann.
 2003 Prentice Hall, Inc. All rights reserved. Customized by Sana Odeh for the use of this class. 1 Introduction to Computers and Programming in JAVA.
CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.
Fundamental Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
Computer Science A 1: 3/2. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated.
CS 106 Introduction to Computer Science I 09 / 11 / 2006 Instructor: Michael Eckmann.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
Introducing Java.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
COMP 110: Introduction to Programming Tyler Johnson January 14, 2009 MWF 11:00AM-12:15PM Sitterson 014.
CS 330 Programming Languages 09 / 04 / 2008 Instructor: Michael Eckmann.
1 Agenda Administration Background Our first C program Working environment Exercise Memory and Variables.
Introduction to Java Thanks to Dan Lunney (SHS). Java Basics File names The “main” method Output to screen Escape Sequence – Special Characters format()
Session One Introduction. Personal Introduction Role of programmers Robot Examination HUD & HID Uploading Code.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
CS 114 – Class 02 Topics  Computer programs  Using the compiler Assignments  Read pages for Thursday.  We will go to the lab on Thursday.
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.
Board Activity Find your seat on the seating chart Login – Remember your login is your first initial your last name and the last three numbers of your.
Week 1 - Friday.  What did we talk about last time?  Our first Java program.
Compiling and the Java Virtual Machine (JVM). The syntax of Pseudocode is pretty loose –visual validation encourages a permissive approach –emphasized.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Chapter 1 Section 1.1 Introduction to Java Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Introduction to programming in the Java programming language.
Jens Dalsgaard Nielsen Jan Dimon Bendtsen Dept. of Electronic Systems Basic Programming INS-basis GF, PDP and HST.
CS 106 Introduction to Computer Science I 01 / 31 / 2007 Instructor: Michael Eckmann.
8/31: Intro to Java, Languages, and Environments Types of programming languages –machine languages –assembly languages –high-level languages Java environment.
© 2004 Pearson Addison-Wesley. All rights reserved ComS 207: Programming I Instructor: Alexander Stoytchev
JAVA Practical Creating our first program 2. Source code file 3. Class file 4. Understanding the different parts of our program 5. Escape characters.
CS 106 Introduction to Computer Science I 01 / 26 / 2007 Instructor: Michael Eckmann.
Introduction Chapter 1 8/31 & 9/1 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
CS101: Introduction to Computer Science Slides adapted from Sedgewick and Wayne Copyright © Your First Java.
Chapter 1 Introduction. Chapter Goals To understand the activity of programming To learn about the architecture of computers To learn about machine code.
CSc 201 Introduction to Java George Wells Room 007, Hamilton Building
CS 106 Introduction to Computer Science I 01 / 22 / 2007 Instructor: Michael Eckmann.
Java FilesOops - Mistake Java lingoSyntax
CS 106 Introduction to Computer Science I 09 / 10 / 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.
Programming for Interactivity Professor Bill Tomlinson Tuesday & Wednesday 6:00-7:50pm Fall 2005.
1/16: Intro to Java, Languages, and Environments Types of programming languages –machine languages –assembly languages –high-level languages Java environment.
CS 106 Introduction to Computer Science I 01 / 24 / 2007 Instructor: Michael Eckmann.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
Chapter 3 Introducing Java. Objectives and Goals 1. Define terminology associated with object- oriented programming. 2. Explain why Java is a widely used.
Chapter 3 GC 101 Java Fundamentals.
CompSci 230 Software Construction
String Output ICS 111: Introduction to Computer Science I
Computer Programming-1 CSC 111
Instructor: Alexander Stoytchev
Presentation transcript:

CS 106 Introduction to Computer Science I 01 / 25 / 2010 Instructor: Michael Eckmann

Michael Eckmann - Skidmore College - CS Spring 2010 Today’s Topics Introduction Homework assignment Review the syllabus Review the policies on academic dishonesty and improper collaboration Introductory comments on programming languages An example of a simple Java program Fill out a questionnaire

Who is your instructor? I'm Mike Eckmann, an Assistant Professor in the Mathematics and Computer Science Dept., Skidmore College. This is my sixth year of teaching at Skidmore. Before coming to Skidmore I was at Lehigh University in PA. I studied Mathematics and Computer Engineering and Computer Science all at Lehigh University. I was employed as a programmer (systems analyst) for eight years. Michael Eckmann - Skidmore College - CS Spring 2010

1 st Homework Read the syllabus and review the improper collaboration policy (both available on our course webpage.)‏ Read Sections 1.1, 1.2 and 1.3 by Friday. Check your sometime after 3p.m. today. I'll send everyone an later today. Please reply to the so I know you got it. In your reply, let me know if you want any additional addresses for yourself added to the class list and what they are. Michael Eckmann - Skidmore College - CS Spring 2010

Syllabus Office hours –Stop by / Text book Class rooms Assignments –Programs & HW Collaboration policy Grading scheme Attendance Workload Readings Note: The most up-to-date syllabus will be found on the course web page. Michael Eckmann - Skidmore College - CS Spring 2010

This semester we will... Be introduced to computer science. Learn programming (in Java)! Solve problems and learn to think like programmers. Hopefully have a fun learning experience. Michael Eckmann - Skidmore College - CS Spring 2010

Computer Science is... more than computer programming. Michael Eckmann - Skidmore College - CS Spring 2010

Programming Languages Machine Assembly High-level –in no particular order –Pascal, C, C++, Basic, Fortran, Java, and many, many more... 4 th generation (e.g. visual)‏ Procedural vs. Object-oriented Michael Eckmann - Skidmore College - CS Spring 2010

Syntax vs. semantics Time flies like an arrow –3 meanings (semantics) for 1 syntax –That's why English is not a programming language! Errors –Run time (crashes)‏ –Compile time (syntax errors)‏ –Logic (semantic errors)‏ Have any of you encountered any of these with software that you use? Which kinds of errors? Examples? Michael Eckmann - Skidmore College - CS Spring 2010

Hello, World! program /* CS106 first program written by Michael Eckmann purpose: print the text “Hello, World!” to the screen */ public class HelloWorld { public static void main(String args[])‏ { System.out.println("Hello, World!"); } // end of main method } // end of HelloWorld class Michael Eckmann - Skidmore College - CS Spring 2010

Discussion of “Hello, World!” comments in source code basic structure of a Java program every Java program must have at least one class every Java program must have exactly one main method System.out.println the use of braces -- begin and end classes and method bodies. Braces are { and } – I call them curly braces. keywords public, static, void, class, etc... see text book section 1.2 Michael Eckmann - Skidmore College - CS Spring 2010

Some common programming mistakes (bugs) Case matters --- upper case letters in class names etc. are different than lower case letters --- e.g. String and string are understood differently by the compiler. Additionally the capitalized String is necessary in the main method argument list declaration. System must be capitalized when referring to something like: System.out because System is the name of the class, system with a lower case s is not. Spaces are not allowed in a class name or any identifier / variable name e.g. HelloWorld is legal, Hello World is not. Michael Eckmann - Skidmore College - CS Spring 2010

Some common programming mistakes (bugs) (continued)‏ Double quotes must be paired up when giving the value of a String --- can’t forget the second double quote. Curly braces must be paired correctly. An extra one dangling somewhere in the code will cause errors, same if one is forgotten. Class name must be the same as the main part of the file name. e.g. a public class named HelloWorld must reside in a file named HelloWorld.java --- not in something like HW.java or any other file. Java source code can only be in plain text files. If a Java source code file is stored as a Word document or any other file type besides plain text, the code will not be able to be compiled. Michael Eckmann - Skidmore College - CS Spring 2010

Some common programming mistakes (bugs) (continued)‏ Multi-line comments starting with /* must end with */ and cannot contain a */ in between. The reason is, once the compiler sees /*, it considers everything a comment until the first */ that it sees, then starts interpreting things as code once again. Note: Encountering bugs is a good thing because it helps the learning process --- e.g. when you encounter similar bugs in the future, you’re likely to find the solution more quickly. Michael Eckmann - Skidmore College - CS Spring 2010

Comments Comments are ignored by the compiler Single line comments start with // and the comment continues until a newline Multi-line comments start with /* and end with */ Another type of multi-line comment starts with /** and ends with */ What’s the purpose of comments if the compiler ignores them? Michael Eckmann - Skidmore College - CS Spring 2010

println vs. print println adds a newline character (carriage return) after the String is printed. print does not. Michael Eckmann - Skidmore College - CS Spring 2010

println vs. print System.out.println(“I love java.”); System.out.println(“It tastes good.”); If these two statements were inside the main method's curly braces, then the program would print: I love java. It tastes good. Michael Eckmann - Skidmore College - CS Spring 2010

println vs. print System.out.print(“I love java.”); System.out.println(“It tastes good.”); Will print: I love java.It tastes good. Michael Eckmann - Skidmore College - CS Spring 2010

println vs. print System.out.print(“I love java.”); System.out.print(“It tastes good.”); How will this print? Michael Eckmann - Skidmore College - CS Spring 2010

Phases of Java Programs create / compile the program –Create / Edit the source code of the program –Compile the source code into bytecodes –After the.java file is compiled we get a.class file E.g. if we compile a program called HelloWorld.java the result is HelloWorld.class When we execute the program (via the java interpreter), the interpreter does the following: –Loads the Classes –Verifies the Bytecodes –Interprets the Bytecodes All of these “execution” steps are done on the.class file(s) Michael Eckmann - Skidmore College - CS Spring 2010

Phases of Java Programs see figure 1.1 in your text on page 9. It contains a diagram showing the creation and execution of a Java program. terminology you need to understand –source code –compile, build –bytecode –execute, run Michael Eckmann - Skidmore College - CS Spring 2010

Phases of Java Programs terminology you need to understand –source code (= the.java files)‏ –compile, build (the source code into bytecode)‏ –bytecode (= the.class files)‏ –execute, run (the.class file(s) using the Java bytecode interpreter)‏ Michael Eckmann - Skidmore College - CS Spring 2010

Eclipse Eclipse is the integrated development environment that we will use for this course. You are free to use others but I will give instructions for Eclipse and show examples during labs, etc. in Eclipse Let's try it. Michael Eckmann - Skidmore College - CS Spring 2010