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

Slides:



Advertisements
Similar presentations
Designing a Program & the Java Programming Language
Advertisements

INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
 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.
The Java Programming Language  Simple – but abstract  Safe  Platform-independent ("write once, run anywhere")  Has a Rich growing library  Designed.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
How do we make our HelloTester.java program do something? The java in our HelloTester.java file won’t do anything by itself. We need to tell the computer.
CHAPTER 1 INTRODUCTION GOALS  To understand the activity of programming  To learn about the architecture of computers  To learn about machine code and.
Aalborg Media Lab 21-Jun-15 Software Design Lecture 1 “ Introduction to Java and OOP”
1 Programming & Programming Languages Overview l Machine operations and machine language. l Example of machine language. l Different types of processor.
1. 2 Chapter 1 Introduction to Computers, Programs, and Java.
Chapter 1 - Introduction. Ch 1Goals To understand the activity of programming To learn about the architecture of computers To learn about machine code.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
IB Computer Science II Paul Bui
Microsoft Visual Basic 2012 CHAPTER ONE Introduction to Visual Basic 2012 Programming.
Microsoft Visual Basic 2005 CHAPTER 1 Introduction to Visual Basic 2005 Programming.
Computer Science 1710: Object- Oriented Programming 1 Spring 2007 Instructor: Andrew Vardy.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design.
Topics Introduction Hardware and Software How Computers Store Data
Week 1 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
COMP 110: Introduction to Programming Tyler Johnson January 14, 2009 MWF 11:00AM-12:15PM Sitterson 014.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 1 Introduction to Computers and Programming.
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.
Introduction to Computers and Java Chapter 1.3. A Sip of Java: Outline History of the Java Language Applets A First Java Program Compiling a Java Program.
©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 1 Chapter 1 Introduction.
Chapter 1 Introduction. Goal to learn about computers and programming to compile and run your first Java program to recognize compile-time and run-time.
Session One Introduction. Personal Introduction Role of programmers Robot Examination HUD & HID Uploading Code.
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.
Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. Chapter 1 – Introduction.
ICOM 4015: Advanced Programming Lecture 1 Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. Reading: Chapter One: Introduction.
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.
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 ( ปรับปรุง )
Copyright © 2014 by John Wiley & Sons. All rights reserved.1 Chapter 1 - Introduction.
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.
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.
J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition Second Edition D.S. Malik D.S. Malik.
1 WELCOME TO CIS 1068! Instructor: Alexander Yates.
A.Abhari CPS1251 Topic 1: Introduction to Computers Computer Hardware Computer components Connecting Computers Computer Software Operating System (OS)
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.
Chapter 1 - Introduction. Announcements Info Sheet Web Site: Lab Hours NotecardsPictures.
Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design.
1. COMPUTERS AND PROGRAMS Rocky K. C. Chang September 6, 2015 (Adapted from John Zelle’s slides)
ITP 109 Week 2 Trina Gregory Introduction to Java.
Microsoft Visual Basic 2015 CHAPTER ONE Introduction to Visual Basic 2015 Programming.
Chapter 1 – Introduction
Introduction To recognize compile-time and run-time errors
John Woodward A Simple Program – Hello world
CSC201: Computer Programming
Topics Introduction Hardware and Software How Computers Store Data
GC101 Introduction to computer and program
Introduction to Visual Basic 2008 Programming
Chapter Goals To learn about computers and programming
Chapter 1 – Introduction
Java programming lecture one
Goals To learn about computers and programming
CS190/295 Programming in Python for Life Sciences: Lecture 1
Topics Introduction Hardware and Software How Computers Store Data
Computer Programming-1 CSC 111
Presentation transcript:

Chapter 1 Introduction

Chapter Goals 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

Prerequisites Computer savvy (file management, text editing) Problem solving skills Time management High school math (algebra, trigonometry) No prior programming background required

What Is Programming? Computers are programmed to perform tasks Different tasks = different programs Program  Sequence of basic operations executed in succession  Contains instruction sequences for all tasks it can execute Sophisticated programs require teams of highly skilled programmers and other professionals

Self Check 1.What is required to play a music CD on a computer? 2.Why is a CD player less flexible than a computer? 3.Can a computer program develop the initiative to execute tasks in a better way than its programmers envisioned?

Answers 1.A program that reads the data on the CD and sends output to the speakers and the screen. 2.A CD player can do one thing–play music CDs. It cannot execute programs. 3.No–the program simply executes the instruction sequences that the programmers have prepared in advance.

Anatomy of a Computer Central processing unit  Chip  Transistors Storage  Primary storage: Random-access memory (RAM)  Secondary storage: e.g. hard disk  Removable storage devices: e.g.: floppy disks, tapes, CDs

Anatomy of a Computer Peripherals Executes very simple instructions Executes instructions very rapidly General purpose device

Central Processing Unit Figure 1: Central Processing Unit

A Memory Module with Memory Chips Figure 2: A Memory Module with Memory Chips

A Hard Disk Figure 3: A Hard Disk

A Motherboard Figure 4: A Motherboard

Schematic Diagram of a Computer Figure 5: Schematic Diagram of a Computer

The ENIAC Figure 6: The ENIAC

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

Answers 4.In secondary storage, typically a hard disk. 5.The central processing unit.

Machine Code Java Virtual Machine (JVM) – a typical sequence of machine instructions is: 1.Load the contents of memory location Load the value If the first value is greater than the second value, continue with the instruction that is stored in memory location 240. Machine instructions are encoded as numbers: Continued…

Machine Code Compiler translates high-level language to machine code

Self Check 6.What is the code for the Java virtual machine instruction "Load the contents of memory location 100"? 7.Does a person who uses a computer for office work ever run a compiler?

Answers No–a compiler is intended for programmers, to translate high-level programming instructions into machine code.

The Java Programming Language Simple Safe Platform-independent ("write once, run anywhere") Rich library (packages) Designed for the internet

Applets on a Web Page Figure 7: Applets on a Web Page

Self Check 8.What are the two most important benefits of the Java language? 9.How long does it take to learn the entire Java library?

Answers 8.Safety and portability. 9.No one person can learn the entire library–it is too large.

Becoming Familiar with your Computer Log in Locate the Java compiler Understand files and folders  Programs are kept in files  File: a collection of items of information that are kept together  Files have names, and the rules for legal names differ from one system to another  Files are stored in folders or directories; these file containers can be nested Continued…

Becoming Familiar with your Computer Write a simple program (later) Save your work  Develop a strategy for keeping backup copies of your work

A Shell Window Figure 8: A Shell Window

An Integrated Development Environment Figure 9: An Integrated Development Environment

Nested Folders Figure 10: Nested Folders

Self Check 10.How are programming projects stored on a computer? 11.What do you do to protect yourself from data loss when you work on programming projects?

Answers 10.Programs are stored in files, and files are stored in folders or directories. 11.You back up your files and folders.

File HelloTester.java 1: public class HelloTester 2: { 3: public static void main(String[] args) 4: { 5: // Display a greeting in the console window 6: 7: System.out.println("Hello, World!"); 8: } 9: } Output Hello, World!

HelloTester in a Console Window Figure 11: Running the HelloTester Program in a Console Window

HelloTester in an IDE Figure 12: Running the HelloTester Program in an Integrated Development Environment

A Simple Program Figure 13: Calling a Method System Class System.out Object println Method public class ClassName public static void main(String[] args) // comment Method call

Syntax 1.1: Method Call object.methodName(parameters) Example: System.out.println("Hello, Dave!"); Purpose: To invoke a method of an object and supply any additional parameters

Self Check 12.How would you modify the HelloTester program to print the words "Hello," and "World!" on two lines? 13.Would the program continue to work if you omitted the line starting with // ? 14.What does the following set of statements print? System.out.print("My lucky number is"); System.out.println( );

Answers Yes–the line starting with // is a comment, intended for human readers. The compiler ignores comments. 14.The printout is My lucky number is12. It would be a good idea to add a space after the is. System.out.println("Hello,"); System.out.println("World");

Errors Syntax errors Detected by the compiler Logic errors Detected (hopefully) through testing System.ouch.print("..."); System.out.print("Hello); System.out.print("Hell");

Self Check 15.Suppose you omit the // characters from the HelloTester.java program but not the remainder of the comment. Will you get a compile-time error or a run-time error? 16.How can you find logic errors in a program?

Answers 15.A compile-time error. The compiler will not know what to do with the word display. 16.You need to run the program and observe its behavior.

The Compilation Process Figure 14: From Source Code to Running Program

The Edit—Compile—Loop Test Figure 15: The Edit—Compile—Loop Test

Self Check 17.What do you expect to see when you load a class file into your text editor? 18.Why can't you test a program for run-time errors when it has compiler errors?

Answers 17.A sequence of random characters, some funny-looking. Class files contain virtual machine instructions that are encoded as binary numbers. 18.When a program has compiler errors, no class file is produced, and there is nothing to run.