Computer Programming-1 CSC 111. Chapter 1 : Introduction

Similar documents
Chapter 1 Computer and Programming. By Zerihun Alemayehu

Introduction to Java Programming

Programming 1. Lecture 1 COP 3014 Fall August 28, 2017

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

The Programming Process Summer 2010 Margaret Reid-Miller

CHAPTER 1 Introduction to Computers and Java

Programming 1 - Honors

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

0 Introduction: Computer systems and program development

Chapter 1: An Overview of Computers and Programming Languages. Objectives. Objectives (cont d.) Introduction

Fundamentals of Programming. Lecture 1: Introduction to C Programming

Chapter 1 Introduction to Computers and C++ Programming

Computer Fundamentals

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

Introduction to Computers and Java

Week 1 Introduction to Computer and Algorithm (Part1) UniMAP Sem II 11/12 DKT121: Basic Computer Programming 1

Fundamentals of Programming Session 1

Week 0: Intro to Computers and Programming. 1.1 Why Program? 1.2 Computer Systems: Hardware and Software. Hardware Components

Software Concepts. It is a translator that converts high level language to machine level language.

Fundamentals of Programming (Python) Basic Concepts. Ali Taheri Sharif University of Technology Spring 2018

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

From High Level to Machine Code. Compilation Overview. Computer Programs

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

Introduction to Computers and Java

Java and Software Design

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

C++ Programming Language Lecture 1 Introduction

BITG 1113: Introduction To Computers And Programming Language LECTURE 1 LECTURE 1 1

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

Fundamentals of Programming Session 1

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

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

Outline. Introduction to Programming (in C++) Introduction. First program in C++ Programming examples

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

Computer Principles and Components 1

AP Computer Science A: Java Programming

Programming 1. Lecture 1 COP 3014 Fall August 28, 2018

Problem Solving and Program Design - Chapter 1. Cory L. Strope

Chapter 1: Introduction to Computers and Programming

Computer is an electronic machine that can receive, store, transform and output data of all kinds (image, text, numeric, graphics and sound).

Lab # 2. For today s lab:

An Introduction to Computers and Java CSC 121 Spring 2015 Howard Rosenthal

Laboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information

The Computer System. Hardware = Physical Computer. Software = Computer Programs. People = End Users & Programmers. people

Computers in Engineering COMP 208. Computer Structure. Computer Architecture. Computer Structure Michael A. Hawker

Chapter 1 Introduction to Computers and C++ Programming

Chapter 3: Operating-System Structures

Chapter 1 Introduction to Computers, Programs, and Java

CHAPTER 1: INTRODUCTION TO COMPUTERS AND PROGRAMMING. 1 Muhalim Mohamed Amin Faculty of

CSc 2010 Principles of Computer Science, Fall 2013 Practice Problems for Midterm 3* * 3 17 % 9-20 % (26 / 7) "2"

Topics. Hardware and Software. Introduction. Main Memory. The CPU 9/21/2014. Introduction to Computers and Programming

EKT 120/4 Computer Programming KOLEJ UNIVERSITI KEJURUTERAAN UTARA MALAYSIA

Programming Languages FILS Andrei Vasilateanu

Java Programming. Zheng-Liang Lu. Java 301 Summer Department of Computer Science & Information Engineering National Taiwan University

Engineering Computing M1H Together Towards A Green Environment

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

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

Chapter 3: Operating-System Structures

Object-Oriented Programming in Java

Programming Fundamentals (CS 302 ) Dr. Ihsan Ullah. Lecturer Department of Computer Science & IT University of Balochistan

Getting Started. Chapter 1. Java Programming FROM THE BEGINNING. Chapter 1: Getting Started

Java Programming. Zheng-Liang Lu. Java 308 Spring Department of Computer Science & Information Engineering National Taiwan University

Introduction to Computers. Joslyn A. Smith

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

Introduction to Computers and Programming Languages. CS 180 Sunil Prabhakar Department of Computer Science Purdue University

Administration Computers Software Algorithms Programming Languages

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

Chapter 1 INTRODUCTION

An Introduc+on to Computers and Java CSC 121 Spring 2017 Howard Rosenthal

Introduction to Java. Lecture 1 COP 3252 Summer May 16, 2017

Java Puzzle Ball Nick Ristuccia

Outline. Program development cycle. Algorithms development and representation. Examples.

Chapter 1 Introduction to Computers and Programming

C++ Spring Break Packet 11 The Java Programming Language

Operating System Structure

IT151: Introduction to Programming (java)

Module 1: Introduction to Computers, Programs, and Java

Advanced Object-Oriented Programming Introduction to OOP and Java

SKILL AREA 304: Review Programming Language Concept. Computer Programming (YPG)

Lab 4: Introduction to Programming

OS and Computer Architecture. Chapter 3: Operating-System Structures. Common System Components. Process Management

2 Introduction to Java. Introduction to Programming 1 1

Introduction to Computers and Visual Basic.Net Pearson Education, Inc. All rights reserved.

What is Java Platform?

CSI31 Introduction to Computer Programming I. Dr. Sharon Persinger Fall

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

Chapter 3: Operating-System Structures

Introduction to Computers

SCSP Programming Technique C

Università degli Studi di Bologna Facoltà di Ingegneria. Principles, Models, and Applications for Distributed Systems M

Introduction to Computers and Java

Last class: OS and Architecture. OS and Computer Architecture

Last class: OS and Architecture. Chapter 3: Operating-System Structures. OS and Computer Architecture. Common System Components

Introduction to Computers and Java

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

AP Computer Science A

Transcription:

Computer Programming-1 CSC 111 Chapter 1 : Introduction

Chapter Outline What a computer is What a computer program is The Programmer s Algorithm How a program that you write in Java is changed into a form that your computer can understand Characteristics of Java Page 2

Computer What Is a Computer? Executes statements (computations/logical decisions) Hardware :Physical devices of computer system Software: Programs that run on computers Central Processing Unit Control Unit Input device Output Device Arithmetic/Logic Unit Memory Unit My data My Progam Page 3

Computer Organization Six logical units of computer system Input unit (Mouse, keyboard) Output unit (Printer, monitor, audio speakers) Memory unit (Retains input and processed information) Central processing unit (CPU) which consists of: Control unit (Supervises operation of other devices) Arithmetic and logic unit (ALU) (Performs calculations) Secondary storage unit (Hard drives, floppy drives) Page 4

What a computer program is? For a computer to be able to perform specific tasks (i.e. print what grade a student got on an exam), it must be given instructions to do the task. The set of instructions that tells the computer to perform specific tasks is known as a computer program Page 5

Levels of Abstraction Human thought Pseudo-Natural Language (English, Arabic) High Level Programming Language (C, C++, Java, ) Machine Code Page 6

The Programmer s Algorithm An algorithm is a finite sequence of instructions that produces a solution to a problem. The programmer s algorithm: Define the problem. Plan the problem solution. Code the program. Compile the program. Run the program. Test and debug the program. Page 7

Defining the Problem The problem must be defined in terms of: Input: Data to be processed. Output: The expected result. Look for nouns in the problem statement that suggest output and input. and processing: The statements to achieve. Look for verbs to suggest processing steps. input data Keyboard Processing output data Screen Page 8

Input and Output Inputs Can come from many sources, such as users, files, and other programs Can take on many forms, such as text, graphics, and sound Outputs Can also take on many forms, such as numbers, text, graphics, sounds, or commands to other programs Page 9

Example 1 Area and Perimeter of a rectangle Input Length width Processing Area = length*width Perimeter = 2*( length + width) Output Area Perimeter Page 10

Example 2 Sum and Average of 5 numbers Input five number x1, x2, x3, x4, x5 Processing Sum = x1+x2+x3+x4+x5 Average = Sum/5 Output Sum Average Page 11

Example 3 Area and Perimeter of a circle Input Radius PI Processing Area = PI * Radius * Radius Perimeter = 2 * PI * Radius Output Area Perimeter Page 12

Planning the Solution When planning, algorithms are used to outline the solution steps using Englishlike statements, called pseudocode. Page 13

Coding the Program Coding is writing the program in a formal language called Programming Language. Programming Language : A set of rules, symbols and special words used to write statements. The program is written by translating the algorithm steps into a programming language statements. The written program is called Source code and it is saved in a file with.java extension. Algorithm Coding Pseudocode Translating Program Source Code (The.java ) Page 14

Why Coding in Programming Languages We write computer programs (i.e. a set of instructions) in programming languages such as C, C++, and Java. We use these programming languages because they are easily understood by humans But then how does the computer understand the instructions that we write? Page 15

Compiling Computer Programs Computers do not understand programs written in programming languages such as C++ and Java Programs must first be converted into machine code that the computer can run A Software that translates a programming language statements into machine code is called a compiler Program Source code Compiling Machine code Translating Machine Code Page 16

Programming Language Compiler A compiler is a software that: Checks the correctness of the source code according to the language rules. Syntax errors are raised if some rules were violated. Translates the source code into a machine code if no errors were found. Page 17

Platform dependent Compiling Because different platforms, or hardware architectures along with the operating systems (Windows, Macs, Unix), require different machine code, you must compile most programs separately for each platform. Page 18

Compiling Java Programs The Java compiler produces bytecode (a.class file) not machine code from the source code (the.java file). Bytecode is converted into machine code using a Java Interpreter Source Code Bytecode Page 19

Platform Independent Java Programs Compiling You can run bytecode on an computer that has a Java Interpreter installed Hello.java Hello.class Page 20

Multipurpose Java Compiling Page 21

Running The Program Running Class Loader Bytecode Verifier The Bytecode (the.class file) Bytecode Interpreter JVM Operating System Hardware Page 22

The Java Virtual Machine Components The Class Loader stores bytecodes in memory Bytecode Verifier ensures bytecodes do not violate security requirements Bytecode Interpreter translates bytecodes into machine language Page 23

The Java Virtual Machine The class Loader, the Bytecode Verifier and Interpreter constitute the Java Virtual Machine (JVM). JVM is platform specific. The interpreter translates the bytecodes into specific machine commands. Page 24

Testing and Debugging the Testing Program Be sure that the output of the program conforms with the input. There are two types of errors: Logical Errors: The program run but provides wrong output. Runtime errors: The program stop running suddenly when asking the OS executing a non accepted statement (divide by zero, etc). Debugging Find, Understand and correct the error Page 25

Phase 1 Editor Disk Program is created in an editor and stored on disk in a file ending with.java. Phase 2 Compiler Disk Compiler creates bytecodes and stores them on disk in a file ending with.class. Phase 3 Class Loader Disk Primary Memory.... Class loader reads.class files containing bytecodes from disk and puts those bytecodes in memory. Phase 4 Bytecode Verifier Primary Memory Bytecode verifier confirms that all bytecodes are valid and do not violate Java s security restrictions..... Phase 5 Interpreter Primary Memory.... Interpreter reads bytecodes and translates them into a language that the computer can understand, possibly storing data values as the program executes. Page 26

Some Characteristics of Java Object-Oriented Combines data and behavior into one unit objects Provides Data abstraction and encapsulation Decompose program into objects. Programs are collections of interacting and cooperating objects. Platform-independent Portable Architecture neutral Write-once, run-anywhere Secure The bytecode verifier of the JVM : checks untrusted bytecode controls the permissions for high level actions. Page 27