Ch 1Goals. Chapter 1 - Introduction. 1.2 Anatomy of a Computer. 1.1 What is Programming? 1.2 Anatomy of a Computer

Similar documents
Introduction to programming

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

Chapter 2: Elements of Java

Chapter 1 Fundamentals of Java Programming

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals

CS 106 Introduction to Computer Science I

Java CPD (I) Frans Coenen Department of Computer Science

How to use the Eclipse IDE for Java Application Development

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored?

Java Basics: Data Types, Variables, and Loops

Lesson 06: Basics of Software Development (W02D2

Machine Architecture and Number Systems. Major Computer Components. Schematic Diagram of a Computer. The CPU. The Bus. Main Memory.

Introduction to Java Applications Pearson Education, Inc. All rights reserved.

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

Chapter 3. Input and output. 3.1 The System class

An Introduction to Computer Science and Computer Organization Comp 150 Fall 2008

The programming language C. sws1 1

6.1. Example: A Tip Calculator 6-1

Topics. Parts of a Java Program. Topics (2) CS 146. Introduction To Computers And Java Chapter Objectives To understand:

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

Install Java Development Kit (JDK) 1.8

Introduction to Java

3 SOFTWARE AND PROGRAMMING LANGUAGES

Chapter 1 Java Program Design and Development

Management Challenge. Managing Hardware Assets. Central Processing Unit. What is a Computer System?

Programming Languages CIS 443

MICROPROCESSOR AND MICROCOMPUTER BASICS

Building Java Programs

CS 40 Computing for the Web

Chapter 1. Introduction to Computers, Programs, and Java

Building Java Programs

Parts of a Computer. Preparation. Objectives. Standards. Materials Micron Technology Foundation, Inc. All Rights Reserved

Software. Programming Language. Software. Instructor Özgür ZEYDAN. Bülent Ecevit University Department of Environmental Engineering

Moving from CS 61A Scheme to CS 61B Java

Memory Systems. Static Random Access Memory (SRAM) Cell

CMPT 183 Foundations of Computer Science I

CS 51 Intro to CS. Art Lee. September 2, 2014

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

AP Computer Science Java Mr. Clausen Program 9A, 9B

CHAPTER 1 ENGINEERING PROBLEM SOLVING. Copyright 2013 Pearson Education, Inc.

ATSBA: Advanced Technologies Supporting Business Areas. Programming with Java. 1 Overview and Introduction

Computer Programming I

File class in Java. Scanner reminder. Files 10/19/2012. File Input and Output (Savitch, Chapter 10)

Chapter 2. println Versus print. Formatting Output withprintf. System.out.println for console output. console output. Console Input and Output

Computer Organization

LAB4 Making Classes and Objects

Cobol. By: Steven Conner. COBOL, COmmon Business Oriented Language, one of the. oldest programming languages, was designed in the last six

C Programming. for Embedded Microcontrollers. Warwick A. Smith. Postbus 11. Elektor International Media BV. 6114ZG Susteren The Netherlands

Chulalongkorn University International School of Engineering Department of Computer Engineering Computer Programming Lab.

Block diagram of typical laptop/desktop

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1

AP Computer Science Static Methods, Strings, User Input

Figure 1: Graphical example of a mergesort 1.

Embedded Software development Process and Tools: Lesson-4 Linking and Locating Software

Chapter 12 Programming Concepts and Languages

EKT150 Introduction to Computer Programming. Wk1-Introduction to Computer and Computer Program

Lecture 5: Java Fundamentals III

Copyright 2012 Pearson Education, Inc. Chapter 1 INTRODUCTION TO COMPUTING AND ENGINEERING PROBLEM SOLVING

=

Outline. hardware components programming environments. installing Python executing Python code. decimal and binary notations running Sage

Mobile App Design Project #1 Java Boot Camp: Design Model for Chutes and Ladders Board Game

Basics of Computer 1.1 INTRODUCTION 1.2 OBJECTIVES

Computer System: User s View. Computer System Components: High Level View. Input. Output. Computer. Computer System: Motherboard Level

D06 PROGRAMMING with JAVA. Ch3 Implementing Classes

CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages. Nicki Dell Spring 2014

Software: Systems and Application Software

Programming Logic controllers

PERFORMANCE ENHANCEMENTS IN TreeAge Pro 2014 R1.0

A+ Guide to Managing and Maintaining Your PC, 7e. Chapter 1 Introducing Hardware

Programming Languages

CS 111 Classes I 1. Software Organization View to this point:

(Refer Slide Time: 02:39)

Java Crash Course Part I

AP Computer Science A - Syllabus Overview of AP Computer Science A Computer Facilities

C# and Other Languages

Installing Java (Windows) and Writing your First Program

Programming Languages

Tutorial 0A Programming on the command line

Python Programming: An Introduction to Computer Science

WA2099 Introduction to Java using RAD 8.0 EVALUATION ONLY. Student Labs. Web Age Solutions Inc.

Ch. 10 Software Development. (Computer Programming)

Obj: Sec 1.0, to describe the relationship between hardware and software HW: Read p.2 9. Do Now: Name 3 parts of the computer.

Installing Java. Table of contents

Sample CSE8A midterm Multiple Choice (circle one)

ECE 122. Engineering Problem Solving with Java

Chapter 3: Operating-System Structures. Common System Components

Lab Experience 17. Programming Language Translation

Division of Informatics, University of Edinburgh

X86-64 Architecture Guide

Java Classes. GEEN163 Introduction to Computer Programming

Microsoft Office Outlook 2013: Part 1

REMOTE DEVELOPMENT OPTION

1 Introduction. 2 An Interpreter. 2.1 Handling Source Code

CPU Organisation and Operation

Appendix A Using the Java Compiler

Kernel Types System Calls. Operating Systems. Autumn 2013 CS4023

1001ICT Introduction To Programming Lecture Notes

Transcription:

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 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 Interacts with devices Executes programs CPU Central Processing Unit (CPU) - Heart of the computer Made of a chip (AMD, Intel, etc), millions of transistors Executes instructions given by a program 1.2 Anatomy of a Computer Storage where data is kept 3 types primary, secondary, removable 1

1.2 Anatomy of a Computer Computers communicate through a network Peripheral devices allow interaction with humans 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 Assembly High Level Language Machine Code The most basic level of instructions Everything is represented with numbers (read in binary) Looks like this: 00010101 00101000 (binary) 21 40 (decimal) This is the only language the CPU knows What s s the problem? CPUs perform very primitive operations only Add, subtract, load from memory 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? Each CPU uses a different set of instructions Each CPU translates different digits to mean different things 2

Assembly A slight step up from machine Uses words and numbers 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 The conversion is done by the compiler Very complicated and sophisticated, not the focus of this course 1.4 The Java Programming Language Simple Safe more secure, easier to catch errors Platform-independent ("write once, run anywhere") operating system and architecture Rich library (packages) 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 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 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 Files are stored in folders or directories 3

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 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 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 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) 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 ; 4

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 */ 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 We will grade on it! 1.7 Errors Two types of 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 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 Saved as a.java file Must have the same name as the class When converted by the compiler, a class file is created Machine instructions Saved by compiler as.class file 5

Coding loop Edit-compile 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 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 Interactions between objects is the heart of OO style 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 Like a mold, template, or blueprint Objects are instances of classes Ex. Class is Student, instance is Eric Lantz 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 Can you send any message to any object? No, the object must understand the message The class defines the messages that the object can understand 6