Week 1 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.

Slides:



Advertisements
Similar presentations
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Advertisements

Lecture 1: Overview of Computers & Programming
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.
Using Computers CS French Chapter 1.
COSC 120 Computer Programming
16/13/2015 3:30 AM6/13/2015 3:30 AM6/13/2015 3:30 AMIntroduction to Software Development What is a computer? A computer system contains: Central Processing.
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.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Sixth Edition by Tony Gaddis, Judy Walters,
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
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.
Microsoft Visual Basic 2012 CHAPTER ONE Introduction to Visual Basic 2012 Programming.
Microsoft Visual Basic 2005 CHAPTER 1 Introduction to Visual Basic 2005 Programming.
CS102 Introduction to Computer 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.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
INTRODUCTION TO COMPUTING
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 1 Introduction to Computer Science.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming 1.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Computer Hardware Introduction. Computer Hardware Introduction The basic form of a computer is this: PROCESSING MEMORY INPUTOUTPUT But let’s look inside.
Computer Hardware and Software Introduction Mr. Smith AP Computer Science A.
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.
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.
Computer Hardware and Software Introduction Mr. Smith AP Computer Science A.
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.
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.
Fundamental Programming: Fundamental Programming K.Chinnasarn, Ph.D.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
CHAPTER 1 INTRODUCTION. CHAPTER GOALS To understand the activity of programming To understand the activity of programming To learn about the architecture.
Mrs. Ulshafer August, 2013 Java Programming Chapter 1.
Fall 2006Slides adapted from Java Concepts companion slides1 Introduction Advanced Programming ICOM 4015 Lecture 1 Reading: Java Concepts Chapter 1.
Jens Dalsgaard Nielsen Jan Dimon Bendtsen Dept. of Electronic Systems Basic Programming INS-basis GF, PDP and HST.
Multimedia and Computers Introduction to Computers.
1 TOPIC 1 INTRODUCTION TO COMPUTER SCIENCE AND PROGRAMMING Topic 1 Introduction to Computer Science and Programming Notes adapted from Introduction to.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
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 09/04/13. Change Your Password  The command is: passwd In the lab first do : ssh -Y onyx  You will have to see me to change it, if you forget.
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.
Week1: Introduction to Computer Networks. Copyright © 2012 Cengage Learning. All rights reserved.2 Objectives 2 Describe basic computer components and.
Chapter 1 - Introduction. Announcements Info Sheet Web Site: Lab Hours NotecardsPictures.
Brief Version of Starting Out with C++ Chapter 1 Introduction to Computers and Programming.
Microsoft Visual Basic 2015 CHAPTER ONE Introduction to Visual Basic 2015 Programming.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Java Programming: From the Ground Up
Chapter 1 – Introduction
Department of Computer Science,
Introduction to Visual Basic 2008 Programming
Introduction
Chapter Goals To learn about computers and programming
Chapter 1 – Introduction
Java programming lecture one
Goals To learn about computers and programming
Introduction CSC 111.
Computer Programming-1 CSC 111
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

Week 1 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham

Week 1 Topics What is Programming? The Anatomy of a Computer Translating Human-Readable Programs to Machine Code The Java Programming Language The Structure of a Simple Program Compiling and Running a Java Program Errors Algorithms

1.1.1 What is Programming? A computer must be programmed to perform tasks. Different tasks require different programs. A computer executes a sequence of very basic operations in rapid succession A program can balance a checkbook; process words; play a game A sophisticated program is composed of extremely primitive operations

1.1.1 What is Programming Cont. A typical primitive operation may be: –Put a red dot onto this screen position –Send the letter A to the printer –Get a number from this location in memory –Add up two numbers –If this value is negative, continue the program at that instruction The creation of a sophisticated program may require a team of many highly skilled programmers, graphic artists, and other professionals

1.1.2 The Anatomy of a Computer At the heart of a computer lies the central processing unit (CPU). It consists of a single chip (integrated circuit) or a small number of chips. The computer keeps data and programs in storage. There are two kinds of storage. Primary storage, also called random-access memory (RAM) or simply memory, is fast and expensive and is made from memory chips. It loses all its data when the power is turned off.

1.1.2 The Anatomy of a Computer Cont. Secondary storage, usually a hard disk, provides less expensive storage and persists without electricity. Some computers are self-contained units, whereas others are interconnected through networks. Home computers are usually connected to the internet via a dialup or broadband connection. Most computers have removable storage devices that can access data or programs such as zip drives, flash drives, tapes or compact discs (CDs)

1.1.2 The Anatomy of a Computer Cont. The CPU, the RAM and the electronics controlling the hard disk and other devices are interconnected through a set of electrical lines called a bus A motherboard contains the CPU, the RAM and connectors to peripheral devices (monitor, speakers, printer, mouse, keyboard, etc.) The CPU reads machine instructions from memory which direct it to communicate with memory, secondary storage and peripheral devices

1.1.3 Translating Human-Readable Programs to Machine Code A CPU executes machine instructions Machine instructions are very simple, are encoded as numbers and stored in memory, and can be executed very quickly Because machine instructions are encoded as numbers, it is difficult to write programs in machine code High-level programming languages such as Java allow you to describe tasks at a higher conceptual level than machine code

1.1.3 Translating Human-Readable Programs to Machine Code Cont. These machine instructions: –Load the contents of memory location 40 –Load the value 100 –If the first value is greater than the second value, continue with the instructions that is stored in memory location 240 might be encoded something like this:

1.1.3 Translating Human-Readable Programs to Machine Code Cont. This Java code (high-level instructions): if (intRate > 100) System.out.println(“Interest rate error”); might be compiled and translated into A compiler is a sophisticated program that translates programs written in a high-level language into machine code

1.1.4 The Java Programming Language Java was originally designed for programming consumer devices, but it was first successfully used to write internet applets Java was designed to be safe and portable, benefiting both internet users and students Java has a very large library There are packages in the Java library for graphics, user interface design, cryptography, networking, sound, database storage, and many other purposes.

1.1.4 The Java Programming Language Cont. Even expert Java programmers cannot hope to know the contents of all of the packages Focus on learning those parts of the library that you need for your programming projects Although you will learn a good deal about the Java language and the most important library packages, keep in mind that the central goal of this course is not to make you memorize Java minutiae, but to teach you how to think about programming.

1.1.5 The Structure of a Simple Program File HelloTester.java: public class HelloTester { public static void main(String[] args) { // Display a greeting to the console window System.out.println(“Hello World!”); } Output: Hello, World!

1.1.5 The Structure of a Simple Program Cont. Java is case sensitive. You must be careful about distinguishing between upper and lowercase letters. Lay out your programs so that they are easy to read Classes are the fundamental building blocks of Java programs Almost every Java application contains a class with a main method. When the application starts, the instructions in the main method are executed.

1.1.5 The Structure of a Simple Program Cont. Each class contains definitions of methods Each method contains a sequence of instructions Use comments to help human readers understand your program A method is called by specifying an object, the method name, and the method parameters A String is a sequence of characters enclosed in quotation marks

1.1.5 The Structure of a Simple Program Cont. Calling a Method: System.out.println(“Hello World!”); Object MethodParameters

1.1.6 Compiling and Running a Java Program You use an editor to write your Java program statements When you save your program statements, it becomes source code and will have a.java extension, for example HelloTester.java A successful compile of your source code will create virtual machine instructions called class files and will have a.class extension, for example HelloTester.class

1.1.6 Compiling and Running a Java Program Cont. From Source Code to Running Program Editor Source File Compiler Class files and Library files Virtual Machine Running Program

1.1.7 Errors A syntax error is a violation of the rules of the programming language. The compiler detects syntax errors. System.ouch.println(“Hello World!”); A logic error causes a program to take an action that the programmer did not intend. You must test your programs to find logic errors. System.out.println(“Hello Word!”);

1.1.8 Algorithms An algorithm is a sequence of steps that is unambiguous, executable and terminating Common algorithms we will cover later on in the course includes finding a minimum or maximum number in a list, sorting a list, searching a list Pseudocode is an informal description of a sequence of steps for solving a problem.

1.1.8 Algorithms Cont. The Program Development Process: o Understand the problem o Develop and describe an algorithm o Test the algorithm with different inputs o Translate the algorithm into Java o Compile and test your program

1.1.8 Algorithms Cont. Example: A salesperson is paid $5.00 for a transaction (sale) less than $100, 15% of sales for a sale between $100 and $1000 inclusive, and $200 for a sale greater than $1000 Read a list that contains a salesperson name, transaction amount, and write to a commission amount the calculated commission

1.1.8 Algorithms Cont. for each entry in the list: if the sale amount is less than 100 then write 5.00 to the commission field if the sale amount is between 100 and 1000 then write.15 x sale amount to the commission field if the sale amount is greater than 1000 then write to the commission field end conditional logic end repetition logic

Reference: Big Java 4th Edition by Cay Horstmann What is Programming? (section 1.1 in Big Java) The Anatomy of a Computer (section 1.2 in Big Java) Translating Human-Readable Programs to Machine Code (section 1.3 in Big Java) The Java Programming Language (section 1.4 in Big Java) The Structure of a Simple Program (section 1.5 in Big Java) Compiling and Running a Java Program (section 1.6 in Big Java) Errors (section 1.7 in Big Java) Algorithms (section 1.8 in Big Java) PC Block Diagram from: pagers.com/computer/pc-block-diagram.htm