Java and Software Design

Similar documents
Command-line interface DOS Graphical User interface (GUI) -- Windows

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

CHAPTER 1 Introduction to Computers and Java

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

Class List. Java Must Have. Class Goals. Class Goals. Schedule

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

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

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

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

Chapter 1: Introduction to Computers and Programming

Computer Principles and Components 1

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

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

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

8/16/12. Computer Organization. Architecture. Computer Organization. Computer Basics

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

The Programming Process Summer 2010 Margaret Reid-Miller

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

CSC 121 Spring 2017 Howard Rosenthal

Information Science 1

Introduction to Java Programming

COMP Computer Basics. Yi Hong May 13, 2015

Elements of Computers and Programming Dr. William C. Bulko. What is a Computer?

CSCE150A. Administrivia. Overview. Hardware. Software. Example. Program. Pseudocode. Flowchart. Control Structures. Hello World Program CSCE150A

Computer Science & Engineering 150A Problem Solving Using Computers

Programming 1 - Honors

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

Introduction to Computers and Java

Introduction to Computers and Java

9/11/08 (c) 2008 Matthew J. Rutherford Class (c) 2008 Matthew J. Rutherford Class

Computer Fundamentals

A Set Of Machine Language Instructions For A Program Is Called Source Code >>>CLICK HERE<<<

0 Introduction: Computer systems and program development

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

SCSP Programming Technique C

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

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

Intermediate Programming & Design (C++) Notation

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

Chapter 1 Overview of Programming and Problem Solving By C.K. Liang

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

Introduction to Object-Oriented Programming

C++ Programming Language Lecture 1 Introduction

Chapter 1 Computer and Programming. By Zerihun Alemayehu

Computer Programming-1 CSC 111. Chapter 1 : Introduction

Chapter 1 Introduction to Computers and C++ Programming

Computer Software: Introduction

Chapter 1 Introduction to Computers and Programming

Introduction to Computers and Java

CMSC 104 -Lecture 2 John Y. Park, adapted by C Grasso

Week 1 Introduction to Programming

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

CS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007

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

COP 1170 Introduction to Computer Programming using Visual Basic

Downloaded From :

Introduction to Computers and Java

Introduction to Computers and Java

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

Introduction to Computers and Java

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

Computing and compilers

An Overview of the Computer System. Kafui A. Prebbie 24

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

CSC180: Lecture 2. Wael Aboulsaadat.

Lesson 01 Introduction

Chapter 1 Introduction to Computers, Programs, and Java

COMP-202 Unit 1: Introduction. CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics

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

Computer Hardware and Software Introduction. Mr. Smith AP Computer Science A

Lecture 1: Introduction to Java

Introduction to Computers, Programs, and Java. CSE 114, Computer Science 1 Stony Brook University

CSC116: Introduction to Computing - Java

Basic Programming Language Syntax

COMP-202 Unit 1: Introduction. CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics

A Review of Chapter 5 and. CSc 2010 Spring 2012 Instructor: Qian Hu

Lecture 1 - Introduction (Class Notes)

Information Technology Essentials

An Introduction to Python (TEJ3M & TEJ4M)

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

Chapter 1. Introduction to Programming and Visual Basic Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of

CSC116: Introduction to Computing - Java

Algorithm: 1. Introduction

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

C H A P T E R 1. Introduction to Computers and Programming

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

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

Chapter. Focus of the Course. Object-Oriented Software Development. program design, implementation, and testing

Technology in Action. Chapter Topics. Scope creep occurs when: 3/20/2013. Information Systems include all EXCEPT the following:

Components of a Computer System

Machine Architecture and Number Systems

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

Designing Computers. The Von Neumann Architecture. The Von Neumann Architecture. The Von Neumann Architecture

1) Which of the following is an example of a programming language? 1) A) Microsoft Word B) English C) HTML D) Java

The Von Neumann Architecture. Designing Computers. The Von Neumann Architecture. CMPUT101 Introduction to Computing - Spring 2001

Which statement regarding computer programs is correct? Which statement best describes a computer program?

CMPUT101 Introduction to Computing - Summer 2002

Fundamentals of Programming. Lecture 1: Introduction to C Programming

Course Outline. Introduction to java

Transcription:

Introduction to Java and Software Design Jindal Consulting Chapter 1 Overview of Programming and Problem Solving Slides by Varun Jindal 1

Chapter 1 Topics Computer Programming Programming Life-Cycle Phases Developing an Algorithm Machine Language vs. High Level Languages Compilation, Execution and Interpretation Computer Components Computing Profession Ethics and Responsibilities Problem-Solving Techniques 2

What is Computer Programming? It is the process of specifying the data types and the operations for a computer to apply to data in order to solve a problem. STEP 1 STEP 2 STEP 3... 3

Programming Life Cycle Phases 1 Problem-Solving 2 Implementation 3 Maintenance 4

Problem-Solving Phase ANALYZE the problem and SPECIFY what the solution must do. Develop a GENERAL SOLUTION (ALGORITHM) to solve the problem. VERIFY that your solution really solves the problem. 5

Sample Problem A programmer needs an algorithm to determine an employee s weekly wages. How would the calculations be done by hand? 6

One Employee s Wages During one week an employee works 52 hours at the hourly pay rate $24.75 How much is the employee s wages? Assume a 40.0 hour normal work week. Assume an overtime pay rate factor of 1.5 40 x $ 24.75 = $ 990.00 12 x 1.5 x $ 24.75 = $ 445.50 $ 1435.50 7

Weekly Wages, in General If hours is over 40.0, then wages = (40.0 * payrate) + (hours - 40.0) * 1.5 *payrate RECALL EXAMPLE ( 40 x $ 24.75 ) + ( 12 x 1.5 x $ 24.75 ) = $1435.50 otherwise, wages = hours * payrate 8

An Algorithm is... step-by-step instructions for solving a problem in a finite amount of time using a finite amount of data. 9

Algorithm to Determine an Employee s Weekly Wages 1. Get the employee s hourly pay rate 2. Get the hours worked this week 3. Calculate this week s regular wages 4. Calculate this week s overtime wages (if any) 5. Add the regular wages to overtime wages (if any) to determine total wages for the week 10

What is a Programming Language? It is a language with strict grammatical rules, symbols, and special words used to construct a computer program. 11

Implementation Phase: Program Translating your algorithm into a programming language is called CODING. With Java, you use Documentation -- your written comments Compiler -- translates your program into Bytecode Java Virtual Machine -- translates Bytecode into machine language 12

Implementation Phase: Test TESTING your program means executing (running) your program on the computer, to see if it produces correct results. If it does not, then you must find out what is wrong with your program or algorithm and fix it. This is called debugging. 13

Maintenance Phase USE and MODIFY the program to meet changing requirements or correct errors that show up in using it. Maintenance begins when your program is put into use and accounts for the majority of effort on most programs. 14

Programming Life Cycle 1 Problem-Solving Analysis and Specification General Solution ( Algorithm ) Verify 2 Implementation Concrete Solution ( Program ) Test 3 Maintenance Use Maintain 15

Programming Shortcut? Problem PROBLEM-SOLVING PHASE Algorithm Shortcut? Code TEST THINKING IMPLEMENTATION CODE PHASE 16

Binary Representation of Data Circuit states correspond to 0 and 1. Bit (short for binary digit) refers to a single 0 or 1. Bit patterns represent data. 1 byte = 8 bits 1 KB 1 MB = 1024 bytes = 1024 x 1024 = 1,048,576 bytes 17

How Many Possible Digits? Binary (Base 2) Numbers use 2 digits: JUST 0 and 1 Decimal (Base 10) Numbers use 10 digits: 0 THROUGH 9 18

Machine Language Is not portable Runs only on specific type of computer Is made up of binary-coded instructions (strings of 0s and 1s) Is the language that can be directly used by the computer. 19

Assembly Language Is machine dependent. Compilers translate assembly language into machine language. Runs only on specific type of computer. Is made up of English-like abbreviations like LOAD, STORE, ADD. 20

High Level Languages Are portable. Generally compilers translate high-level language into machine language. User writes program in language similar to natural language. Examples -- FORTRAN, COBOL, Pascal, C, C++ Many are standardized by ISO/ANSI to provide an official description of the language. 21

Three C++ Program Stages myprog.cpp myprog.obj myprog.exe SOURCE OBJECT EXECUTABLE written in C++ written in machine language written in machine language via compiler via linker other code from libraries, etc. 22

Java Portability Payroll.java SOURCE Payroll.class BYTECODE EXECUTABLES Windows PC running JVM Java Program Java Bytecode Unix box running JVM via compiler javac via interpreter JVM Macintosh running JVM 23

Java programming language Achieves portability by using both a compiler and an interpreter. First, a Java compiler translates a Java program into an intermediate Bytecode--not machine language. Then, an interpreter program called the Java Virtual Machine (JVM) translates a single instruction in the Bytecode program to machine language and immediately runs it, one at a time. 24

Java s 5 Basic Control Structures A sequence is a series of statements that executes one after another. Selection (branch) executes different statements depending on certain conditions. Loop (repetition) repeats statements while certain conditions are met. A subprogram breaks the program into smaller units. Asynchronous control handles events that originate outside our program, such as button clicks. 25

SEQUENCE Statement Statement Statement... 26

SELECTION (branch) IF Condition THEN Statement1 ELSE Statement2 Statement1 Statement Condition... Statement2 27

LOOP (repetition) WHILE Condition DO Statement1 Condition False... Statement 28

SUBPROGRAM (function) SUBPROGRAM1... SUBPROGRAM1 a meaningful collection of SEQUENCE, SELECTION, LOOP, SUBPROGRAM 29

ASYNCHRONOUS CONTROL EVENT EVENTHANDLER a subprogram executed when an event occurs 30

Object-Oriented Programming An object is a collection of data values and associated operations. A class is a description of one or more like objects. 31

An Object of class Time OPERATIONS DATA Set Increment Write... Time Private data: hrs 8 mins 25 secs 42 32

Basic Computer Components Peripherals Input Device Central Processing Unit ( CPU ) Control Unit Output Device Arithmetic Logic Unit Auxiliary Storage Device Memory Unit ( RAM & Registers ) 33

Memory Unit Is an ordered sequence of storage cells, each capable of holding a piece of data. Each memory cell has a distinct address. The information held can be input data, computed values, or program instructions. 34

Central Processing Unit (CPU) Has 2 components to execute program instructions -- Arithmetic/Logic Unit performs arithmetic operations, and makes logical operations. Control Unit controls the order in which your program instructions are executed. 35

Peripheral Devices Are input, output, or auxiliary storage devices attached to a computer. Input Devices include keyboard and mouse. Output Devices include printers, video display, LCD screens. Auxiliary Storage Devices include disk drives, CD-ROM and DVD-ROM drives. 36

Computing Profession Ethics Copy software only with permission from the copyright holder. Give credit to another programmer by name whenever using his/her code. Use computer resources only with permission. Guard the privacy of confidential data. Use software engineering principles to develop software free from errors. 37

Problem Solving Techniques ASK QUESTIONS -- about the data, the process, the output, error conditions. LOOK FOR FAMILIAR THINGS -- certain situations arise again and again. SOLVE BY ANALOGY -- it may give you a place to start. USE MEANS-ENDS ANALYSIS -- Determine the I/O and then work out the details. 38

More Problem Solving Techniques DIVIDE AND CONQUER -- break up large problems into manageable units. BUILDING-BLOCK APPPROACH -- can you solve small pieces of the problem? MERGE SOLUTIONS -- instead of joining them end to end to avoid duplicate steps. OVERCOME MENTAL BLOCK -- by rewriting the problem in your own words. 39

A Basic Java Program 1 2 3 4 5 6 7 8 public class test { } public static void main (String[ ] args) { System.out.println("Hello World!"); return; } 1. Save inside a file named test.java 2. To compile: javac test.java (produces test.class) 3. To execute: java test (executes test.class) 1. Prints out Welcome World! to the screen 40