Chapter 1 - Introduction. Ch 1Goals To understand the activity of programming To learn about the architecture of computers To learn about machine code.

Slides:



Advertisements
Similar presentations
INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
Advertisements

 2005 Pearson Education, Inc. All rights reserved Introduction.
Chapter 1: Introduction
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.
Chapter 1: An Overview of Computers and Programming Languages J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
CHAPTER 1 INTRODUCTION GOALS  To understand the activity of programming  To learn about the architecture of computers  To learn about machine code and.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Aalborg Media Lab 21-Jun-15 Software Design Lecture 1 “ Introduction to Java and OOP”
1 Programming Languages Translation  Lecture Objectives:  Be able to list and explain five features of the Java programming language.  Be able to explain.
Topic 1: Introduction to Computers and Programming
1. 2 Chapter 1 Introduction to Computers, Programs, and Java.
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
COMP Computer Basics Yi Hong May 13, 2015.
Microsoft Visual Basic 2012 CHAPTER ONE Introduction to Visual Basic 2012 Programming.
Microsoft Visual Basic 2005 CHAPTER 1 Introduction to Visual Basic 2005 Programming.
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Chapter Introduction to Computers and Programming 1.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
Chapter 1 Introduction to Programming and the Java Language.
Introducing Java.
Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design.
COMPUTER SOFTWARE Section 2 “System Software: Computer System Management ” CHAPTER 4 Lecture-6/ T. Nouf Almujally 1.
Topics Introduction Hardware and Software How Computers Store Data
Week 1 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 1 Introduction to Computer Science.
1 TOPIC 1 INTRODUCTION TO COMPUTER SCIENCE AND PROGRAMMING Topic 1 Introduction to Computer Science and Programming Notes adapted from Introduction to.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
CISC105 General Computer Science Class 1 – 6/5/2006.
Big Java by Cay Horstmann Copyright © 2008 by John Wiley & Sons. All rights reserved. Chapter One: Introduction.
Week 1 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 1 Chapter 1 Introduction.
Session One Introduction. Personal Introduction Role of programmers Robot Examination HUD & HID Uploading Code.
Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. Chapter 1 – Introduction.
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.
Big Java by Cay Horstmann Copyright © 2008 by John Wiley & Sons. All rights reserved. Chapter One: Introduction.
Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. Chapter 1 – Introduction ( ปรับปรุง )
King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science Department Lecture 1 : Introduction.
Guide to Programming with Python Chapter One Getting Started: The Game Over Program.
Lecture 1 Introduction Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
CHAPTER 1 INTRODUCTION. CHAPTER GOALS To understand the activity of programming To understand the activity of programming To learn about the architecture.
Fall 2006Slides adapted from Java Concepts companion slides1 Introduction Advanced Programming ICOM 4015 Lecture 1 Reading: Java Concepts Chapter 1.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Jens Dalsgaard Nielsen Jan Dimon Bendtsen Dept. of Electronic Systems Basic Programming INS-basis GF, PDP and HST.
1 TOPIC 1 INTRODUCTION TO COMPUTER SCIENCE AND PROGRAMMING Topic 1 Introduction to Computer Science and Programming Notes adapted from Introduction to.
Beginning Snapshots Chapter 0. C++ An Introduction to Computing, 3rd ed. 2 Objectives Give an overview of computer science Show its breadth Provide context.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Chapter 1 Introduction. Chapter Goals To understand the activity of programming To learn about the architecture of computers To learn about machine code.
CHAPTER 1 INTRODUCTION. CHAPTER GOALS To understand the activity of programming To learn about the architecture of computers To learn about machine code.
Chapter 1 Introduction. Components of a Computer CPU (central processing unit) Executing instructions –Carrying out arithmetic and logical operations.
Computer and Programming. Computer Basics: Outline Hardware and Memory Programs Programming Languages and Compilers.
Chapter 1 - Introduction. Announcements Info Sheet Web Site: Lab Hours NotecardsPictures.
Microsoft Visual Basic 2015 CHAPTER ONE Introduction to Visual Basic 2015 Programming.
Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.
Chapter 1 Introduction 2nd Semester H
CSC201: Computer Programming
Topics Introduction Hardware and Software How Computers Store Data
Introduction to Visual Basic 2008 Programming
Lecture 1: Introduction to JAVA
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
Chapter 1 – Introduction
Java programming lecture one
Topics Introduction Hardware and Software How Computers Store Data
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Computer Programming-1 CSC 111
Presentation transcript:

Chapter 1 - Introduction

Ch 1Goals To understand the activity of programming To learn about the architecture of computers To learn about machine code and high level programming languages To become familiar with your computing environment and your compiler To compile and run your first Java program To recognize syntax and logic errors

1.1 What is Programming? Computers are programmed to perform tasks Different tasks = different programs Program Sequence of basic operations executed in succession Sequence of basic operations executed in succession Contains instruction sequences for all tasks it can execute Contains instruction sequences for all tasks it can execute How do we produce this program?

1.2 Anatomy of a Computer A computer is a machine that can do certain tasks Stores data Stores data Interacts with devices Interacts with devices Executes programs Executes programs

CPU Central Processing Unit (CPU) - Heart of the computer Made of a chip (AMD, Intel, etc), millions of transistors Made of a chip (AMD, Intel, etc), millions of transistors Executes instructions given by a program Executes instructions given by a program

1.2 Anatomy of a Computer Storage – where data is kept 3 types – primary, secondary, removable 3 types – primary, secondary, removable

1.2 Anatomy of a Computer Computers communicate through a network Peripheral devices allow interaction with humans Speakers, screen, printer, scanner Speakers, screen, printer, scanner RAM, Disks, peripherals connected to CPU via the bus

Where is a program stored when it is not currently running? Which part of the computer carries out arithmetic operations, such as addition and multiplication?

1.3 Translating Human-Readable Programs to Machine Code There are actually multiple levels upon which a program can be written Machine Instructions Machine Instructions Assembly Assembly High Level Language High Level Language

Machine Code The most basic level of instructions Everything is represented with numbers (read in binary) Everything is represented with numbers (read in binary) Looks like this: Looks like this: (binary) (decimal) This is the only language the CPU knows

What’s the problem? CPUs perform very primitive operations only Add, subtract, load from memory Add, subtract, load from memory Leads to coding of several hundred lines to perform one simple operation Leads to coding of several hundred lines to perform one simple operation Not Intuitive Can you look at 1000 numbers and tell what the program is doing? Can you look at 1000 numbers and tell what the program is doing? Each CPU uses a different set of instructions Each CPU translates different digits to mean different things Each CPU translates different digits to mean different things

Assembly A slight step up from machine Uses words and numbers load 40 load 40 Still needs as many instructions as machine language, but is slightly easier to read.

High Level High level is much more expressive One statement is converted into several machine code instructions One statement is converted into several machine code instructions The conversion is done by the compiler Very complicated and sophisticated, not the focus of this course Very complicated and sophisticated, not the focus of this course

1.4 The Java Programming Language Simple Simple Safe – more secure, easier to catch errors Safe – more secure, easier to catch errors Platform-independent ("write once, run anywhere") – operating system and architecture Platform-independent ("write once, run anywhere") – operating system and architecture Rich library (packages) Rich library (packages) Designed for the Internet Designed for the Internet

Java Virtual Machine Unique to Java Instead of compiling for a particular processor, Java compiles to a virtual processor that is the same for every computer Lesson: The code is the same no matter what computer you are on, so you don’t have to make a Mac version and a PC version, etc.

Flaws Fully object-oriented nature can be confusing to beginning programmers Many revisions made – make sure you update if you work from home to Java 5.0 (1.5) Rich libraries  So much to learn

1.5 Becoming Familiar w/ your Computer Very important to familiarize yourself with your computer Understand how to find files, what they are, how do you move them around and name them Understand how to find files, what they are, how do you move them around and name them Understand files and folders Programs are kept in files Programs are kept in files File: a collection of items of information that are kept together File: a collection of items of information that are kept together Files have names, and the rules for legal names differ Files have names, and the rules for legal names differ Files are stored in folders or directories Files are stored in folders or directories

1.6 Compiling a Simple Program So how do we actually make a program? In this course, we will use an IDE (Integrated Development Environment) called Eclipse This will help us find mistakes more quickly.

Simple Program Most simple program Outputs a sentence to the console screen Outputs a sentence to the console screen public class FirstProgram { public static void main(String[] args) { //display a greeting in the console window System.out.println(“My First Program!”); }}

Essential Components What does each line mean? public class ClassName A class is an essential part of a java program, all instructions are contained within a class A class is an essential part of a java program, all instructions are contained within a class We create a class called FirstProgram, the file must be called FirstProgram.java We create a class called FirstProgram, the file must be called FirstProgram.java

Method public static void main(String[] args) { // Code goes here } Classes contains methods – specific instructions that can be called Ex. Robot needs method called walk Ex. Robot needs method called walk public void walk() { } Every program must have a method called main – it is the method called first

Parameters public static void main(String[] args) String[] args is a parameter – input given to a method (will learn about more later on) String[] args is a parameter – input given to a method (will learn about more later on)

Body The instructions are the body of a method System.out.println(“My First Program!”); An instruction to print a message to the screen Each instruction ends in a ;

Comments //display a greeting in the console window System.out.println(“My First Program!”); “//” signifies not to execute this line of code Has many uses – here it is to explain what the code is supposed to do Another type of comments: /* Multiple lines of comments about what is going on what is going on*/

Method Call Here, we are calling the method println() on the object System.out

Notes Java is case sensitive class FirstProgram ≠ class firstprogram It is free form – the amount of white space is irrelevant to the computer (although it is important for readability) You could have all instructions on one line, but not very useful to a human You could have all instructions on one line, but not very useful to a human We will grade on it! We will grade on it!

1.7 Errors Two types of errors Compile Time Errors – Syntax errors Compile Time Errors – Syntax errors These are caught when you ask Java to convert your program to machine code Your program must follow a set of rules (just like a sentence in English) Run Time Errors Run Time Errors Not problems in the syntax, but problems in logic Program does not accomplish what the programmer intended

1.8 Compilation Process The code a programmer creates is called the source code Written in Java Written in Java Saved as a.java file Saved as a.java file Must have the same name as the class Must have the same name as the class When converted by the compiler, a class file is created Machine instructions Machine instructions Saved by compiler as.class file Saved by compiler as.class file

Coding loop Edit-compile-test loop Your programming begins with editing a file by writing instructions When done, compile the program. If no compile errors, test the program. If compile errors, go back to editing If there are runtime errors, go back to fix them

Object Oriented Programming What is the point of this course? Not Java – its just a tool Not Java – its just a tool Methodology of programming – OOP Methodology of programming – OOP

Objects & Classes – 2 Main Concepts Object – an entity, something we can imagine (typically a noun) Consists of data values and operations for manipulating those values Consists of data values and operations for manipulating those values Interactions between objects is the heart of OO style Interactions between objects is the heart of OO style Ex. Bank accounts – need Customer, Account, Bank, etc. Ex. Bank accounts – need Customer, Account, Bank, etc.

Classes Class – Instructions for creating objects Defines what objects can and cannot do – how they behave and what info they hold Defines what objects can and cannot do – how they behave and what info they hold Like a mold, template, or blueprint Like a mold, template, or blueprint Objects are instances of classes Ex. Class is Student, instance is Eric Lantz Ex. Class is Student, instance is Eric Lantz Ex2. Class is University, instances could be University of Wisconsin and Cornell Ex2. Class is University, instances could be University of Wisconsin and Cornell

Messages and Methods In order to use objects and classes, coder needs to communicate with them - Messages Ex. Tell Robot to move forward 1 foot Ex. Tell Robot to move forward 1 foot Can you send any message to any object? No, the object must understand the message No, the object must understand the message The class defines the messages that the object can understand The class defines the messages that the object can understand