Chapter 8: Introduction to High-Level Language Programming Invitation to Computer Science, Java Version, Third Edition.

Slides:



Advertisements
Similar presentations
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Advertisements

Copyright © 2002 W. A. Tucker1 Chapter 1 Lecture Notes Bill Tucker Austin Community College COSC 1315.
Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
Chapter 2: Algorithm Discovery and Design
Computers: Tools for an Information Age
Java Programming, 3e Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Guide To UNIX Using Linux Third Edition
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Chapter 6: An Introduction to System Software and Virtual Machines
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
Chapter 8: Introduction to High-Level Language Programming Invitation to Computer Science, C++ Version, Fourth Edition.
Chapter 8 Introduction to High-Level Language Programming.
Chapter 2: Algorithm Discovery and Design
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Programming In C++ Spring Semester 2013 Programming In C++, Lecture 1.
Introduction to High-Level Language Programming
Introduction To System Analysis and design
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
Java Programming, 2E Introductory Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
Programming Languages – Coding schemes used to write both systems and application software A programming language is an abstraction mechanism. It enables.
Programming Languages: Telling the Computers What to Do Chapter 16.
A First Program Using C#
Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Invitation to Computer Science 5th Edition
Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming.
High-Level Programming Languages: C++
Microsoft Visual Basic 2005: Reloaded Second Edition
CIS Computer Programming Logic
UNIVERSITI TENAGA NASIONAL “Generates Professionals” CHAPTER 4 : Part 2 INTRODUCTION TO SOFTWARE DEVELOPMENT: PROGRAMMING & LANGUAGES.
Chapter 1: A First Program Using C#. Programming Computer program – A set of instructions that tells a computer what to do – Also called software Software.
Invitation to Computer Science 5 th Edition Chapter C# Programming in C#
Invitation to Computer Science 6th Edition
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science, C++ Version, Third Edition.
Invitation to Computer Science, Java Version, Second Edition.
Chapter 1 Introduction to Computers and C++ Programming Goals: To introduce the fundamental hardware and software components of a computer system To introduce.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Chapter 1 Section 1.1 Introduction to Java Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
Guide to Programming with Python Chapter One Getting Started: The Game Over Program.
Invitation to Computer Science 5 th Edition Chapter C++ Programming in C++
Introduction to Computer Application (IC) MH Room 517 Time : 7:00-9:30pm.
Module 4 Part 2 Introduction To Software Development : Programming & Languages Introduction To Software Development : Programming & Languages.
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
Chapter 8: Introduction to High-Level Language Programming Invitation to Computer Science, Java Version, Third Edition.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
8-1 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Creating a Java Application and Applet
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
Introduction to OOP CPS235: Introduction.
Objective You will be able to define the basic concepts of object-oriented programming with emphasis on objects and classes by taking notes, seeing examples,
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
CSCI 51 Introduction to Programming Dr. Joshua Stough February 24, 2009.
Evolution of C and C++ n C was developed by Dennis Ritchie at Bell Labs (early 1970s) as a systems programming language n C later evolved into a general-purpose.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
Chapter 1: Introduction to Computers and Programming.
Chapter 7 Introduction to High-Level Language Programming.
Invitation to Computer Science 5 th Edition Chapter Ada Programming in Ada.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
Chapter 8: Introduction to High-Level Language Programming
Chapter 1 Introduction(1.1)
Chapter 8 Introduction to High-Level Language Programming.
Programming Logic and Design Eighth Edition
Presentation transcript:

Chapter 8: Introduction to High-Level Language Programming Invitation to Computer Science, Java Version, Third Edition

Invitation to Computer Science, Java Version, Third Edition 2 Objectives In this chapter, you will learn about Where do we stand? High-level languages Introduction to Java Virtual data storage Statement types

Invitation to Computer Science, Java Version, Third Edition 3 Objectives (continued) Meeting expectations Managing complexity Object-oriented programming Graphical programming The big picture: Software engineering

Invitation to Computer Science, Java Version, Third Edition 4 Where Do We Stand? Early days of computing  Programmers were satisfied with assembly language Programs mostly written by very technically oriented people Later decades  Programmers demanded a more comfortable programming environment Programs were now also written by “nontechie” people

Invitation to Computer Science, Java Version, Third Edition 5 High-Level Languages High-level programming languages  Called third-generation languages  Created to overcome deficiencies of assembly language Expectations of a high-level language program  The programmer need not manage the details of the movement of data items within memory nor exactly where those items are stored

Invitation to Computer Science, Java Version, Third Edition 6 High-level Languages (continued) Expectations of a high-level language program (continued)  Programmer can take a macroscopic view of tasks; “primitive operations” can be larger  Program will be portable  Programming statements will be closer to standard English and use standard mathematical notation

Invitation to Computer Science, Java Version, Third Edition 7 Introduction to Java: A Simple Java Program Comments  Give information to human readers of code Class header  Announces that a class is about to be defined Class  A collection of methods Method  A section of code that performs a service

Invitation to Computer Science, Java Version, Third Edition 8 Figure 8.2 A Simple Java Program

Invitation to Computer Science, Java Version, Third Edition 9 Running a Java Program File containing the Java code  Same name as the class  File extension.java  Example: TravelPlanner.java Running a Java program  Program compiled Example: File TravelPlanner.class created  Translation to object code completed; program linked, loaded, and executed

Invitation to Computer Science, Java Version, Third Edition 10 Virtual Data Storage Identifiers  Names in a programming language Keyword  Has a special meaning in Java Java is a case-sensitive, free-format language Variable  A named location in memory  Must be declared before it can be used

Invitation to Computer Science, Java Version, Third Edition 11 Figure 8.4 Some of the Java Primitive Data Types

Invitation to Computer Science, Java Version, Third Edition 12 Virtual Data Storage (continued) An array  Groups together a collection of memory locations, all storing data of the same type Figure 8.5 A 12-Element Array Hits

Invitation to Computer Science, Java Version, Third Edition 13 Statement Types Input/output statements  Input statement Collects a specific value from the user for a variable within the program  Output statement Writes a message or the value of a program variable to the user’s screen or to a file

Invitation to Computer Science, Java Version, Third Edition 14 Statement Types (continued) Assignment statement  Assigns a value to a program variable Control statement  Directs the flow of control Can cause it to deviate from the usual sequential flow

Invitation to Computer Science, Java Version, Third Edition 15 Input Statements A prompt  A message that tells the user what kind of input the program wants Console class  Not a standard Java class; written for this book  Can be used to handle both the prompt and the retrieval of the value in one statement

Invitation to Computer Science, Java Version, Third Edition 16 Input Statements (continued) Methods  readInt  readDouble  readChar Syntax variable1 = Console.readInt(prompt); variable2 = Console.readDouble(prompt); variable3 = Console.readChar(prompt);

Invitation to Computer Science, Java Version, Third Edition 17 Output Statements Output to the screen System.out.println(string); The string can be  Empty System.out.println();  Literal string System.out.println("Here's your answer." );  Composed of two or more items System.out.println("Give me" + 5);

Invitation to Computer Science, Java Version, Third Edition 18 The Assignment Statement General form variable = expression; Expression is evaluated first; the result is written into the memory location specified on the left

Invitation to Computer Science, Java Version, Third Edition 19 The Assignment Statement (continued) Examples B = 2; Suppose that B is an integer variable A = B + C; Suppose that A, B, and C are integer variables Letter = 'm'; Suppose that Letter is a variable of type char

Invitation to Computer Science, Java Version, Third Edition 20 Control Statements Types of control mechanisms  Sequential Instructions are executed in order  Conditional The choice of which instructions to execute next depends on some condition  Looping A group of instructions may be executed many times

Invitation to Computer Science, Java Version, Third Edition 21 Control Statements (continued) Sequential is default mode of execution Conditional flow of control  Evaluation of a Boolean condition (also called a Boolean expression)  The programming statement to execute next is based on the value of the Boolean condition (true or false)

Invitation to Computer Science, Java Version, Third Edition 22 Control Statements (continued) Conditional flow of control (continued)  if-else statement if (Boolean condition) S1; else S2;  if variation of the if-else statement if (Boolean condition) S1;

Invitation to Computer Science, Java Version, Third Edition 23 Figure 8.10 Conditional Flow of Control (If-Else)

Invitation to Computer Science, Java Version, Third Edition 24 Figure 8.11 If-Else with Empty Else

Invitation to Computer Science, Java Version, Third Edition 25 Control Statements (continued) Looping (iteration)  The loop body may be executed repeatedly based on the value of the Boolean condition  while statement while (Boolean condition) S1;

Invitation to Computer Science, Java Version, Third Edition 26 Figure 8.13 While Loop

Invitation to Computer Science, Java Version, Third Edition 27 Meeting Expectations Java meets the four expectations for a high-level programming language Expectations  The programmer need not manage the details of the movement of data items within memory nor pay any attention to where specifically they are stored

Invitation to Computer Science, Java Version, Third Edition 28 Meeting Expectations (continued) Expectations (continued)  The programmer can take a macroscopic view of tasks, thinking at a higher level of problem solving  Programs written in high-level languages will be portable rather than machine-specific  Programming statements in a high-level language Will be closer to standard English Will use standard mathematical notation

Invitation to Computer Science, Java Version, Third Edition 29 Managing Complexity: Divide and Conquer Divide and conquer  Divide the problem into small pieces  In a computer program Divide the code into modules or subprograms, each of which does some part of the overall task Empower these modules to work together to solve the original problem

Invitation to Computer Science, Java Version, Third Edition 30 Figure 8.20 Structure Charts

Invitation to Computer Science, Java Version, Third Edition 31 Using Methods Method  A module of code in Java  Named using ordinary Java identifiers  By custom, name starts with a lowercase letter

Invitation to Computer Science, Java Version, Third Edition 32 Using Methods (continued) Two types of methods  void method Does not pass any value back to the main method  nonvoid method Returns a single new value back to the main method Overall form of a method invocation class-identifier.method-identifier(argument list)

Invitation to Computer Science, Java Version, Third Edition 33 Writing Methods General form of the method header scope-indicator return-indicator identifier(parameter list) Arguments in Java are passed by value A variable declared within a method can be used only within that method Return statement  Syntax return expression;

Invitation to Computer Science, Java Version, Third Edition 34 Figure 8.27 Some Java Terminology

Invitation to Computer Science, Java Version, Third Edition 35 Object-Oriented Programming: What Is It? Object-oriented programming (OOP)  A program is a simulation of some part of the world that is the domain of interest  Each object is an example drawn from a class of similar objects Key elements of OOP  Encapsulation A class consists of its subtask modules and its properties, and both components are “encapsulated” with the class

Invitation to Computer Science, Java Version, Third Edition 36 What Is It? (continued) Key elements of OOP (continued)  Inheritance Once a class A of objects is defined, a class B of objects can be defined as a “subclass” of A  Polymorphism One name, the name of the service to be performed, has several meanings, depending on the class of the object providing the service

Invitation to Computer Science, Java Version, Third Edition 37 Java and OOP Java is an object-oriented programming language Static method  Can be invoked by giving the class name, a dot, the method name, and a list of arguments Objects: Instances of a class Instance variables: Properties Instance methods: Services

Invitation to Computer Science, Java Version, Third Edition 38 Java and OOP (continued) Syntax to request an object to invoke a method object-identifier.method-identifier(argument list) Calling object  The object that invokes a method

Invitation to Computer Science, Java Version, Third Edition 39 What Have We Gained? Two major advantages of OOP  Software reuse  A more natural “world view”

Invitation to Computer Science, Java Version, Third Edition 40 Graphical Programming: Graphics Hardware Bitmapped display  The screen is made up of thousands of individual picture elements, or pixels, laid out in a two- dimensional grid Frame buffer  Memory that stores the actual screen image Terminal hardware displays the frame buffer value of every individual pixel on the screen

Invitation to Computer Science, Java Version, Third Edition 41 Figure 8.34 Pixel Numbering System in a Bitmapped Display

Invitation to Computer Science, Java Version, Third Edition 42 Graphics Software Graphics library  Contains a collection of software routines that control the setting and clearing of pixels Abstract Windowing Toolkit (AWT)  Contains routines that allow users to create powerful interfaces Swing components  Even more powerful GUI components than AWT

Invitation to Computer Science, Java Version, Third Edition 43 Graphics Software (continued) Graphics class  Contains drawing commands that allow you to Draw geometric shapes (lines, rectangles, ovals, polygons, and so on) Set, change, and define colors Fill in or shade objects Create text in a range of fonts and sizes Produce graphs and charts

Invitation to Computer Science, Java Version, Third Edition 44 The Big Picture: Software Engineering Software life cycle  The overall sequence of steps needed to complete a large-scale software project  Implementation represents a relatively small part of the cycle

Invitation to Computer Science, Java Version, Third Edition 45 Figure 8.36 Steps in the Software Development Life Cycle

Invitation to Computer Science, Java Version, Third Edition 46 Scaling Up Programs written by students  No longer than a few hundred lines Real-world programs  2, 3, or 4 orders of magnitude larger Large-scale software development  Extensive planning and design needed  A team of programmers needed  Software engineering

Invitation to Computer Science, Java Version, Third Edition 47 The Software Life Cycle Each step in the software development life cycle  Has a specific purpose and activities  Should result in a written document The feasibility study Problem specification Program design

Invitation to Computer Science, Java Version, Third Edition 48 The Software Life Cycle (continued) Algorithm selection or development, and analysis Coding Debugging Testing, verification, and benchmarking Documentation Maintenance

Invitation to Computer Science, Java Version, Third Edition 49 Modern Environments Integrated Development Environment (IDE) speeds program development by providing  A text editor  A file manager  A compiler  A linker and loader  Tools for debugging

Invitation to Computer Science, Java Version, Third Edition 50 Summary In a high-level language, the programmer  Need not manage storage nor movement of data values in memory  Can use more powerful program instructions that are more like natural language  Can write a much more portable program Java is an object-oriented, high-level programming language

Invitation to Computer Science, Java Version, Third Edition 51 Summary (continued) In Java, an if-else statement can be used to create a conditional flow of control In Java, a while loop can be used for iteration Software life cycle: Overall sequence of steps needed to complete a large-scale software project