BASICS.

Similar documents
9/11/08 (c) 2008 Matthew J. Rutherford Class (c) 2008 Matthew J. Rutherford Class

Introduction to Computers and Java. Objectives. Outline. Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich.

Introduction to Computers and Java

Introduction to Computers and Java

Introduction to Computers and Java. Objectives. Outline. Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich.

Introduction to Computers and Java

Introduction to Computers and Java

Introduction to Computers and Java

Introduction to Computers and Java

Introduction Basic elements of Java

1.1 Your First Program

CS 177 Recitation. Week 1 Intro to Java

CMSC 150 LECTURE 1 INTRODUCTION TO COURSE COMPUTER SCIENCE HELLO WORLD

CS 11 java track: lecture 1

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

CHAPTER 1 Introduction to Computers and Java

Java Language. Programs. Computer programs, known as software, are instructions to the computer. You tell a computer what to do through programs.

Advanced Programming Introduction

02 B The Java Virtual Machine

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

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

Space Exploration EECS /25

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

Getting Started with Java. Atul Prakash

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

Chapter 1: Introduction to Computers and Programming

1.1 Your First Program

C02: Overview of Software Development and Java

Java Bytecode (binary file)

3 CREATING YOUR FIRST JAVA APPLICATION (USING WINDOWS)

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

1.1 Your First Program

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

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

Chapter 1: Why Program? Computers and Programming. Why Program?

Chapter 1: Why Program? Main Hardware Component Categories 8/23/2014. Main Hardware Component Categories: Why Program?

Lesson 04: Our First Java Program (W01D4

Over-view. CSc Java programs. Java programs. Logging on, and logging o. Slides by Michael Weeks Copyright Unix basics. javac.

Tutorial 1 CSC 201. Java Programming Concepts عؾادئماظربجمةمبادؿكدامماجلاصا

CompSci 125 Lecture 02

Chapter 1 Introduction to Computers, Programs, and Java

Reverse Engineering of Managed Languages

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

Are You Covered? Keith D Gregory Philly JUG 14 October 2009

Week One: Introduction A SHORT INTRODUCTION TO HARDWARE, SOFTWARE, AND ALGORITHM DEVELOPMENT

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

1.1 Your First Program

Lecture 1: Introduction to Java

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

Lecture 1 - Introduction (Class Notes)

ICOM 4015: Advanced Programming

CPS109 Lab 1. i. To become familiar with the Ryerson Computer Science laboratory environment.

Networks Programming Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000)

1.1 Your First Program

Programming Language Concepts: Lecture 2

CSE 431S Final Review. Washington University Spring 2013

Index. Course Outline. Grading Policy. Lab Time Distribution. Important Instructions

Week 2: Data and Output

Chapter 1 Introduction to Computers, Programs, and Java

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

Pla$orm independence and languages. CSCI 136: Fundamentals of Computer Science II Keith Vertanen

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

Computer Basics 1/24/13. Computer Organization. Computer systems consist of hardware and software.

COMP Computer Basics. Yi Hong May 13, 2015

Java Programming. Atul Prakash

Introduction to Computers, Programs, and Java. CSE 114, Computer Science 1 Stony Brook University

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

Chapter 1 Introduction to Computers, Programs, and Java

CHAPTER INTRODUCTION. Final Draft Oct. 15, Slides by Donald W. Smith TechNeTrain.com. Copyright 2013 by John Wiley & Sons. All rights reserved.

Chapter Goals. Contents. 1.1 Computer Programs

COSC 123 Computer Creativity. Introduction to Java. Dr. Ramon Lawrence University of British Columbia Okanagan

Chapter 1. Introduction to Computers and Java Objects. Background information. » important regardless of programming language. Introduction to Java

Full file at

CS 112 Introduction to Programming

Goals. Java - An Introduction. Java is Compiled and Interpreted. Architecture Neutral & Portable. Compiled Languages. Introduction to Java

Computer Basics 1/6/16. Computer Organization. Computer systems consist of hardware and software.

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

AP Computer Science A: Java Programming

Getting started with Java

Objectives. Chapter 1 Introduction to Computers, Programs, and Java. What is a Computer?

Programming Language Concepts: Lecture 1

Chapter 1 Introduction to Computers, Programs, and Java

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

Programming with Java

1.1 Your First Program

Chapter 1: Introduction to Computers, Programs, and Java

CHAPTER 1. Introduction to JAVA Programming

Outline. Overview. Control statements. Classes and methods. history and advantage how to: program, compile and execute 8 data types 3 types of errors

Section 2.2 Your First Program in Java: Printing a Line of Text

AP Computer Science A

CSCI 1103: Introduction

Note that this is essentially the same UML as the State pattern! The intent of each of the two patterns is quite different however:

Inf1-OOP. Textbooks. Who and What. Organisational issues. Why Java? Course Overview. Hello, World! in Java

At its simplest, a computer is a collection of wires, transistors and electrical components that are connected in a specific way When you send

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

Java is a high-level programming language originally developed by Sun Microsystems and released in Java runs on a variety of

Program Development. Program Development. A Foundation for Programming. Program Development

Branching and Boolean Expressions

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

Transcription:

BASICS http://www.flickr.com/photos/oskay/472097903/

CSCI 135 - Fundamentals of Computer Science I 2 Outline Computer Basics Programs and Languages Introduction to the Eclipse IDE Our First Program Comments Algorithms

Hardware and Memory Most modern computers have similar components including Input devices (keyboard, mouse, etc.) Output devices (display screen, printer, etc.) A processor Two kinds of memory (main memory and auxiliary memory).

Main memory Working memory used to store The current program The data the program is using The results of intermediate calculations Usually measured in megabytes or gigabytes (e.g. 8 gigabytes of RAM) RAM is short for random access memory A byte is a quantity of memory

Bits, Bytes, and Addresses A bit is a digit with a value of either 0 or 1. A byte consists of 8 bits. Each byte in main memory resides at a numbered location called its address.

Main Memory Data of all kinds (numbers, letters, strings of characters, audio, video, even programs) are encoded and stored using 1s and 0s. When more than a single byte is needed, several adjacent bytes are used. The address of the first byte is the address of the unit of bytes. When the computer is turned off, main memory is erased (volatile memory).

Auxiliary Memory Auxiliary memory uses devices such as a hard drive, DVD, USB drive, etc. Data (files) need to be saved to the auxiliary memory Data is still stored in bits and bytes When the computer is turned off, this data does not go away (persistent storage)

Programs A program is a set of instructions for a computer to follow. We use programs almost daily (email, word processors, video games, bank ATMs, etc.). When the computer follows the instructions it is running or executing the program.

View of Programming from 10,000 Feet Alice Input string Your program Black box Hi, Alice. How are are? Output string

Languages Machine language Low level, what the hardware understands Tedious and error-prone to write Specific to a particular type of computer Natural language Imprecise and ambiguous Hard to convert to instructions for the hardware High level programming language Good balance between the two extremes

Becoming a Programmer: Step 1 Choose a language and hundreds more

Our Choice: Java Advantages Widely used, modern Freely available, cross-platform Features help novices learn to program No perfect single language You'll learn many other languages C/C++, assembly, Python, C#, JavaScript, PHP... Programming skills translate easily between them James Gosling, father of Java. "There are only two kinds of languages: the ones people complain about and the ones nobody uses." -Bjarne Stroustrup, father of C++

Your First Program http://www.zazzle.com/baby_girls_first_java_program_hello_world_tshirt-235063563751392326 $23.95

How Java Works Source code: Plain text file created in some editor (notepad, vi, TextEdit, Eclipse, DrJava, ) public class HelloWorld { public static void main(string [] args) { System.out.println("Hello world!"); } } HelloWorld.java compiling % javac HelloWorld.java Java bytecode: Intermediate language that any device running Java can understand (humans generally ignore this) Compiled from "HelloWorld.java" public class HelloWorld extends java.lang.object{ public HelloWorld(); Code: 0: aload_0 1: invokespecial #1; //Method java/lang/object."<init>":()v 4: return public static void main(java.lang.string[]); Code: 0: getstatic #2; //Field java/lang/system.out:ljava/io/printstream; 3: ldc #3; //String Hello world! 5: invokevirtual #4; //Method java/io/printstream.println:(ljava/lang/string;)v 8: return } HelloWorld.class

How Java Works Compiled Java bytecode: Intermediate language that any device running Java can understand (humans generally ignore this) from "HelloWorld.java" public class HelloWorld extends java.lang.object{ public HelloWorld(); Code: 0: aload_0 1: invokespecial #1; //Method java/lang/object."<init>":()v 4: return public static void main(java.lang.string[]); Code: 0: getstatic #2; //Field java/lang/system.out:ljava/io/printstream; 3: ldc #3; //String Hello world! 5: invokevirtual #4; //Method java/io/printstream.println:(ljava/lang/string;)v 8: return } HelloWorld.class running % java HelloWorld

Eclipse Eclipse IDE (Integrated Development Environment)

Eclipse Eclipse IDE (Integrated Development Environment) Recommended but not required Free Helpful features: Syntax highlighting Flagging likely mistakes We will use mostly as a text editor Ignoring 95% of its features How to install? See course web site, resources page We'll still learn to work on the command line

Compiling and Running A Java program can involve any number of classes. The class to run will contain the words: public static void main(string[] args) somewhere in the file public class CostCalc { public static void main(string [] args) { } }

Anatomy of a Java Program public class CostCalc { public static void main(string [] args) { } } All the action goes here (for now) Extra things from the command line The input that allows the program to produce variable output % java CostCalc bananas 12 0.21 To buy 12 bananas you will need $2.52 Name of the class, must be in file named CostCalc.java (case sensitive!)

args Array public static void main(string [] args) % java CostCalc bananas 12 0.21 To buy 12 bananas you will need $2.52 identifier meaning value type args[0] args[1] args[2] args.length 1 st thing on command line after Java class name 2 nd thing on command line 3 rd thing on command line after Java class # of things on command line "bananas" String "12" String "0.21" String 3 int

Command line args in Eclipse

Command Line args in Command Shell

Some Terminology DEFINITION Arguments the items inside the parentheses that provide data needed by methods Method the code that is executed when called Variable something that can store data Statement an instruction to the computer; in Java it ends with a semicolon Syntax the grammar rules for a programming language Flow of Control the order in which instructions are executed

Algorithms By designing methods, programmers provide actions for objects to perform. An algorithm describes a means of performing an action. Once an algorithm is defined, expressing it in Java (or in another programming language) usually is easy.

Algorithms An algorithm is a set of instructions for solving a problem. An algorithm must be expressed completely and precisely. Algorithms usually are expressed in English or in pseudocode.

Example: Total Cost of All Items Write the number 0 on the whiteboard. For each item on the list Add the cost of the item to the number on the whiteboard Replace the number on the whiteboard with the result of this addition. Announce that the answer is the number written on the whiteboard.

CSCI 135 - Fundamentals of Computer Science I 27 Summary Computer Basics Programs and Languages Introduction to the Eclipse IDE Our First Program Comments Algorithms