CP122 CS I. Chapter 1: Introduction

Similar documents
CP122 CS I. Hello, World!

Java Programming. What is a program? Programs Recipes. Programs as Recipes 8/16/12. Pancakes In one bowl. mix: 1½ cup flour

! Learn how to think like a computer scientist. ! Learn problem solving. ! Read and write code. ! Understand object oriented programming

CS 177 Recitation. Week 1 Intro to Java

CHAPTER 1 Introduction to Computers and Java

CSE 201 Java Programming I. Smart Coding School website:

Java Programming. What is a program? Programs as Recipes. Programs Recipes 8/20/15. Pancakes In one bowl

COMP163. Introduction to Computer Programming. Introduction and Overview of the Hardware

COMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2016

COMP-202 Unit 1: Introduction. CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics

COMP-202 Unit 1: Introduction. CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics

CompSci 125 Lecture 02

Wentworth Institute of Technology. Engineering & Technology WIT COMP1000. Java Basics

Outline. CIS 110: Introduction to Computer Programming. What is Computer Science? What is computer programming? What is computer science?

Chapter 1: Introduction to Computers and Java

8/23/2014. Chapter Topics. Introduction. Java History. Why Program? Java Applications and Applets. Chapter 1: Introduction to Computers and Java

ALICE: An introduction to progamming

ICOM 4015: Advanced Programming

Announcements Tues., Aug and 2. to call them ( ) ! For next time, read Learning Computing with Robots, chs.

Chapter 1 Introduction to Computers, Programs, and Java

SDKs - Eclipse. SENG 403, Tutorial 2

COMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2015

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

Computer Science II Lecture 1 Introduction and Background

Lab # 2. For today s lab:

CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics. COMP-202 Unit 1: Introduction

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to

Darrell Bethea May 10, MTWRF 9:45-11:15 AM Sitterson 011

Chapter 1 Introduction to Computers, Programs, and Java. What is a Computer? A Bit of History

Lecture 1 - Introduction (Class Notes)

CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics. COMP-202 Unit 1: Introduction

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University

Creating a Program in JCreator. JCreator is then used to create our program. But the first step is to create a new file.

Chapter 3 Intro to Java

3 CREATING YOUR FIRST JAVA APPLICATION (USING WINDOWS)

CMSC 150 LECTURE 1 INTRODUCTION TO COURSE COMPUTER SCIENCE HELLO WORLD

Computers 101. Lecture 1

Computer Hardware and Software Introduction. Mr. Smith AP Computer Science A

Pace University. Fundamental Concepts of CS121 1

Code Ninjas: Introduction to Computer Science. Macomb Science Olympiad Presented by Swati Dharia

Lesson 01 Introduction

MEAP Edition Manning Early Access Program Get Programming with Java Version 1

2/9/2012. Chapter One: Introduction. Chapter Goals

COMPUTER PROGRAMMING LOOPS

Chapter 2: Programming Concepts

Introduction to Computer Science I

Welcome to CSE 142! Zorah Fung University of Washington, Spring Building Java Programs Chapter 1 Lecture 1: Introduction; Basic Java Programs

CS150 Introduction to Computer Science 1. What is CS150? Who Are We? CS150 is a programming course You will learn

Chapter Goals. Chapter One: Introduction. Prerequisites. What Is Programming?

CS 11 java track: lecture 1

CSE 142. Lecture 1 Course Introduction; Basic Java. Portions Copyright 2008 by Pearson Education

Lecture 4: Introduction to Java and your Development Environment

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

An Introduction to Computers and Java CSC 121 Spring 2015 Howard Rosenthal

Certified Core Java Developer VS-1036

Welcome to Python! If you re the type of person who wants to know

Lecture Set 2: Starting Java

Welcome to CSE 142! Whitaker Brand. University of Washington, Winter 2018

Lecture Set 2: Starting Java

Chapter 1 - Introduction. Copyright 2014 by John Wiley & Sons. All rights reserved. 1

INDEX. A SIMPLE JAVA PROGRAM Class Declaration The Main Line. The Line Contains Three Keywords The Output Line

Java Programming Fundamentals - Day Instructor: Jason Yoon Website:

COMP Computer Basics. Yi Hong May 13, 2015

Chapter 1. Introduction to Computers and Programming. M hiwa ahmad aziz

CP122 CS I. Chapter 11: File I/O and Exceptions

CS 231 Data Structures and Algorithms, Fall 2016

Java Basics Lecture: January 26, 2012 (On-line Lecture 1)

Introduction to Java Programming

CSE 1223: Introduction to Computer Programming in Java Chapter 1 Computer Basics

Building Java Programs

How to make a "hello world" program in Java with Eclipse *

Primitive Data, Variables, and Expressions; Simple Conditional Execution

Lecture Notes CPSC 224 (Spring 2012) Today... Java basics. S. Bowers 1 of 8

Computer Science AP 2017 Summer Assignment Mrs. McFarland

Building Java Programs

Week 2: Data and Output

AP Computer Science A: Java Programming

CP122 CS I. Iteration

Building Java Programs

CS 152: Data Structures with Java Hello World with the IntelliJ IDE

Building Java Programs

Introduction to Java. Java Programs Classes, Methods, and Statements Comments Strings Escape Sequences Identifiers Keywords

A Unicorn Named Sparkle Word Search. A New Friend for Sparkle Coloring Sheet. A Unicorn Named Sparkle s First Christmas Coloring Sheet

CSE 142, Summer 2015

Introduction to JAVA

C02: Overview of Software Development and Java

Course Outline. Introduction to java

2 rd class Department of Programming. OOP with Java Programming

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 2: SEP. 8TH INSTRUCTOR: JIAYIN WANG

Supplementary Test 1

Lesson 04: Our First Java Program (W01D4

Introduction Jan. 22, Ch 1

CSc 2010 Principles of Computer Science, Fall 2013 Practice Problems for Midterm 3* * 3 17 % 9-20 % (26 / 7) "2"

CS 121 Intro to Programming:Java - Lecture 2. Professor Robert Moll (+ TAs) CS BLDG

Java Basic Programming Constructs

Building Java Programs

Introduction to Software Development (ISD) David Weston and Igor Razgon

Introduction to Computers and Java

A computer is an electronic device, operating under the control of instructions stored in its own memory unit.

In Java, data type boolean is used to represent Boolean data. Each boolean constant or variable can contain one of two values: true or false.

Transcription:

CP122 CS I Chapter 1: Introduction

Introductions

Webpage and Syllabus cs.coloradocollege.edu/~mwhitehead

Hacker's Tip of the Day Hacker A person interested in how things work. A critical thinker, an endless tinkerer, a knowledge investigator, a bright engineer.

Hacker's Tip of the Day Hacker A person interested in how things work. A critical thinker, an endless tinkerer, a knowledge investigator, a bright engineer. Cracker A person who breaks into computer systems for malicious purposes.

Goals for the Class Learn about programming. Work with algorithms and computational thinking. Figure out what computer science means. Take over the world.

Chapter 1: Introduction What kinds of problems do computer scientists work on? What are the components of a modern computer? What exactly is programming and how is it done?

What do Computer Scientists do? Programming :)

What do Computer Scientists do? Databases How can we efficiently store massive amount of data?

What do Computer Scientists do? Artificial Intelligence Can we make machines smart? Can we make machines smarter than humans?

What do Computer Scientists do? Graphics How can we make beautiful computer games and computergenerated movies?

What do Computer Scientists do? Theory of Computation What is mathematically possible to compute?

What do Computer Scientists do? Programming Languages What kinds of languages can we use to program computers? AlephLanguage println "Hello World!" AppleScript on helloworld() display dialog "Hello World!" buttons {"OK"} end helloworld Awk echo "Hello World" awk '{print $0}' Basic 10 PRINT "HELLO WORLD"

What do Computer Scientists do? Security How can we prevent unwanted access to computer systems?

What do Computer Scientists do? Scientific Computing How can we use computers to solve difficult/large problems in science?

What do Computer Scientists do? Networking and Communication How can we effectively connect computer systems together?

Why Study Computer Science? Do you like solving problems? There are almost endless interesting problems in CS

Why Study Computer Science? Do you like solving problems? There are almost endless interesting problems in CS Do you have varied interests? You can use CS knowledge to write music software, run giant physics simulations, predict the stock market, develop medical software, etc.

Why Study Computer Science?

CNNMoney

Wall Street Journal Best Jobs 2010

Why Study Computer Science? It's an exciting time! Think how different technology is today vs. 10 years ago What will things be like in 20 years? 50 years? 100 years?

Why Study Computer Science? It's an exciting time! Think how different technology is today vs. 10 years ago What will things be like in 20 years? 50 years? 100 years? In 10-20 years, a $2000 computer will be equivalent in processing power to a human brain

Why Study Computer Science? It's an exciting time! Think how different technology is today vs. 10 years ago What will things be like in 20 years? 50 years? 100 years? In 10-20 years, a $2000 computer will be equivalent in processing power to a human brain In 30-40 years, a $2000 computer will be equivalent in processing power to ALL human brains

Computer Hardware Overview

Central Processing Unit (CPU) Execute basic instructions Registers hold the data for calculations Registers get data from memory (RAM) using the LOAD operation High-speed CPU cache speeds up memory data access

Main Memory (Random Access Memory: RAM) Volatile storage of program instructions and data An array of words Address Value 0xde88ca9c 15 0xde88ca9d 0xde88ca9e hi! LOAD......

Secondary Storage (Harddrive) Long-term storage of programs and data Contains a file system for organization of files and directories Solid-state drives are becoming more popular

Other I/O Devices (Keyboard, Monitor, etc.) Interface with the user Provide data input/output

System Bus Connector that links CPU and RAM Built in to the motherboard I/O buses also connect to the System Bus

Cost/Speed of Storage Device Relative Cost Access Time (estimate in ns) CPU Register $$$$ 0.5 CPU Cache $$$ 0.5-1 RAM $$ 100 Harddrive $ 5,000,000

What is a computer program?

How are Computers Programmed? Step 1: Write a.java file in plain text

How are Computers Programmed? Compilation Step 2: Compile the program into a special low-level language that can be executed

How are Computers Programmed? JVM Step 3: Execute the program by loading it with the Java Virtual Machine and launching it on the CPU

How are Computers Programmed in Java? Step 1: Write Java code in a plaintext file (.java file) Step 2: Compile the Java code into a bytecode file (.class file) Step 3: Execute the byte-code in the Java Virtual Machine (JVM)

What Does a Java Program Look Like? public class MyFirstProgram { } public static void main(string[] args) { System.out.println( This is my first program! ); }

What Does a Java Program Look program (chosen by Like? public class MyFirstProgram { This is the name of our us!) } public static void main(string[] args) { System.out.println( This is my first program! ); }

Our program is a class. A What Does a Java Program Look class is a blueprint for Like? creating an object. public class MyFirstProgram { } public static void main(string[] args) { System.out.println( This is my first program! ); }

What Does main is a the Java name Program of a method Look in our class. A Like? method is a block of code that performs a task. public class MyFirstProgram { } public static void main(string[] args) { System.out.println( This is my first program! ); }

What Does Whenever a Java a program Program starts Look running, it always Like? begins executing code in its main method. public class MyFirstProgram { } public static void main(string[] args) { System.out.println( This is my first program! ); }

What Does The body a Java of the main Program method is Look defined inside Like? of these curly braces. public class MyFirstProgram { } public static void main(string[] args) { System.out.println( This is my first program! ); }

What Does Each line a of Java code Program is called a Look statement. Like? This statement prints out some text to the screen. public class MyFirstProgram { } public static void main(string[] args) { System.out.println( This is my first program! ); }

What Does a Java Program Look println stands for Print Like? Line. println is just another method like our main method. public class MyFirstProgram { } public static void main(string[] args) { System.out.println( This is my first program! ); }

What System Does refers to a another Java Program class that Look implements low-level Like? system tasks (like displaying text on the screen) public class MyFirstProgram { } public static void main(string[] args) { System.out.println( This is my first program! ); }

What Does a Java Program Look Like? public class MyFirstProgram { public static void main(string[] args) { System.out.println( This is my first program! ); } } The text This is my first program! is called a String and will be displayed when this programs runs. It is inside quotation marks so it can be distinguished from regular Java instructions.

What Does a Java Program Look Like? public class MyFirstProgram { public static void main(string[] args) { System.out.println( This is my first program! ); } } This String is a parameter being passed to the println method. println has to know what to print, right? The parameter provides that value.

What Does What a do Java public, Program static, and Look void stand for? Like? We'll cover these very soon. public class MyFirstProgram { } public static void main(string[] args) { System.out.println( This is my first program! ); }

Installing Java

Let's Write It and Run It!

Documenting Our Program // This is my first program ever public class MyFirstProgram { } public static void main(string[] args) { /* This is a multiline comment Display a message to the screen */ System.out.println( This is my first program! ); }

When Things Go Horribly Wrong Compiler error: a syntactical problem with a program (the program doesn't obey the syntax rules of the programming language)

When Things Go Horribly Wrong Compiler error: a syntactical problem with a program (the program doesn't obey the syntax rules of the programming language) Run-time error: the program generates an error (called an exception) E.g. Division by zero

When Things Go Horribly Wrong Compiler error: a syntactical problem with a program (the program doesn't obey the syntax rules of the programming language) Run-time error: the program generates an error (called an exception) E.g. Division by zero Logical error: the program doesn't do the right thing

Algorithm Informal definition: a series of steps to solve a problem

No-Knead Bread Recipe Combine 3 cups flour, 1.5 cups water, 0.25 tsps yeast, and 2 tsps salt in a bowl Mix the ingredients Wait for the bread to rise Dump the dough into a bread pan Bake for 56 minutes at 400 degrees (if you live at 6500') Let bread cool for 1 hour before eating

Algorithm Formal definition: a sequence of steps that is unambiguous, executable, and terminating

No-Knead Bread Algorithm? Combine 3 cups flour, 1.5 cups water, 0.25 tsps yeast, and 2 tsps salt in a bowl Mix the ingredients Wait for the bread to rise Dump the dough into a bread pan Bake for 56 minutes at 400 degrees (if you live at 6500') Let bread cool for 1 hour before eating

Break!