Program Control using Java - Theory

Slides:



Advertisements
Similar presentations
4 Control Statements: Part 1.
Advertisements

2008 Pearson Education, Inc. All rights reserved Control Statements: Part 1.
More on Algorithms and Problem Solving
3 Decision Making: Equality and Relational Operators A condition is an expression that can be either true or false. Conditions can be formed using the.
C How to Program, 6/e Summary © by Pearson Education, Inc. All Rights Reserved.
 Control structures  Algorithm & flowchart  If statements  While statements.
ITEC113 Algorithms and Programming Techniques
INSTRUCTOR: SHIH-SHINH HUANG Windows Programming Using Java Chapter4: Control Statements Part I.
Chapter 2- Visual Basic Schneider
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Introducing Algorithms, Pseudocode and.
Chapter 3 - Structured Program Development
Introduction to Computers and Programming Lecture 5 New York University.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 3 - Structured Program Development Outline.
CMT Programming Software Applications Week 3 Dr. Xiaohong Gao TP Room B107 Control Structures.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control.
Structured Program Development in C
Lecture 3 Structured Program Development in C
Java™ How to Program, 9/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Introduction to Programming Lecture Number:. What is Programming Programming is to instruct the computer on what it has to do in a language that the computer.
Spring 2005, Gülcihan Özdemir Dağ Lecture 3, Page 1 BIL104E: Introduction to Scientific and Engineering Computing, Spring Lecture 3 Outline 3.1 Introduction.
C++ If….Else Statements and Flowcharts October 10, 2007.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Computer Organization Six logical units in every.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Wage Calculator Application: Introducing.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Structural Program Development: If, If-Else Outline.
Structured Program Development Outline 2.1Introduction 2.2Algorithms 2.3Pseudo code 2.4Control Structures 2.5The If Selection Structure 2.6The If/Else.
Software Life Cycle What Requirements Gathering, Problem definition
Lecture 2: Logical Problems with Choices. Problem Solving Before writing a program Have a thorough understanding of the problem Carefully plan an approach.
Pseudocode When designing an ALGORITHM to solve a problem, Pseudocode, can be used. –Artificial, informal language used to develop algorithms –Similar.
Dale Roberts Program Control using Java - Selection Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.
C Lecture Notes 1 Structured Program Development.
Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control Structures 3.5The If Selection Structure 3.6The.
1 C++ How to Program, 7/e © by Pearson Education, Inc. All Rights Reserved. 4.
 2000 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Dale Roberts Object Oriented Programming using Java - OOD to OOP: ATM Case Study Dale Roberts, Lecturer Computer Science, IUPUI
Dale Roberts Program Control using Java - Repetition Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.
Dale Roberts 1 Program Control - Algorithms Department of Computer and Information Science, School of Science, IUPUI CSCI N305.
C Programming 2002 Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control Structures 3.5The If Selection.
Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control Structures 3.5The If Selection Structure 3.6The.
 Pearson Education, Inc. All rights reserved Control Statements: Part 1.
Structured Program Development Angela Chih-Wei Tang ( 唐 之 瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2010.
1 Lecture 3 Control Structures else/if and while.
Chapter 3 Structured Program Development Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng University.
Visual Basic Flowcharts October 10, Turn in your vocabulary words before you leave!
1 Lecture 2 Control Structures: Part 1 Selection: else / if and switch.
FLOWCHARTING AND ALGORITHMS
1 JavaScript/Jscript 2 Control Structures I. 2 Introduction Before programming a script have a –Thorough understanding of problem –Carefully planned approach.
Dale Roberts Program Control Department of Computer and Information Science, School of Science, IUPUI Fall 2003 CSCI 230 Dale Roberts, Lecturer
Chapter 3 Structured Program Development in C C How to Program, 8/e, GE © 2016 Pearson Education, Ltd. All rights reserved.1.
Algorithm: procedure in terms of
Control Statements: Part 1
Chapter 2- Visual Basic Schneider
Computer Programming Flowchart.
Chapter 2.1 Control Structures (Selection)
Chapter 8 - JavaScript: Control Statements I
CSC113: Computer Programming (Theory = 03, Lab = 01)
Lecturer CS & IT Department UOS MBDIN
Programming Fundamentals
Lecture 2: Logical Problems with Choices
MSIS 655 Advanced Business Applications Programming
Structured Program
Chapter 3 - Structured Program Development
Chapter 2- Visual Basic Schneider
Chapter 3 - Structured Program Development
Chapter 2- Visual Basic Schneider
Chapter 4 - Control Structures: Part 1
Dale Roberts, Lecturer IUPUI
WJEC GCSE Computer Science
WRITING AN ALGORITHM, PSEUDOCODE, AND FLOWCHART LESSON 2.
Structural Program Development: If, If-Else
Presentation transcript:

Program Control using Java - Theory Department of Computer and Information Science, School of Science, IUPUI Program Control using Java - Theory Dale Roberts, Lecturer Computer Science, IUPUI E-mail: droberts@cs.iupui.edu

Algorithms Algorithms is the are part of the problem solving process ‘A’ in STAIR. All computing problems can be solved by executing a series of actions in a specific order, called an algorithm Algorithm: procedure in terms of Actions to be executed The order in which these actions are to be executed Program control Specify order in which statements are to executed

Definition of Algorithm Definition of an Algorithm consists of unambiguous & computable operations produce a result halt in a finite amount of time. Some scientists add a restriction that the algorithm must halt in a reasonable amount of time. Why would there be resistance to this idea?

Control Structures Sequential execution Transfer of control Statements executed one after the other in the order written Transfer of control When the next statement executed is not the next one in sequence Overuse of goto statements led to many problems Bohm and Jacopini All programs written in terms of 3 control structures Sequence structures: Built into C. Programs executed sequentially by default Selection structures: Java has three types: if, if/else, and switch Repetition structures: Java has three types: while, do/while and for

Pseudocode Pseudocode An informal language similar to English Helps programmers develop algorithms Does not run on computers Should contain input, output and calculation actions Should not contain variable declarations For each student i in the Class Calculate the student’s average score If the average score >= 90A% Then Assign Student[i] grade to ‘A’ End if End For

Control Structures Sequential execution Transfer of control Statements are normally executed one after the other in the order in which they are written Transfer of control Specifying the next statement to execute that is not necessarily the next one in order Can be performed by the goto statement Structured programming eliminated goto statements

4.4 Control Structures (Cont.) Bohm and Jacopini’s research Demonstrated that goto statements were unnecessary Demonstrated that all programs could be written with three control structures The sequence structure, The selection structure and The repetition structure

4.4 Control Structures (Cont.) UML activity diagram (www.uml.org) Models the workflow (or activity) of a part of a software system Action-state symbols (rectangles with their sides replaced with outward-curving arcs) represent action expressions specifying actions to perform Diamonds Decision symbols (explained in Section 4.5) Merge symbols (explained in Section 4.7)

Control Structures Flowchart Graphical representation of an algorithm Drawn using certain special-purpose symbols connected by arrows called flowlines Rectangle symbol (action symbol): Indicates any type of action Oval symbol: Indicates the beginning or end of a program or a section of code Single-entry/single-exit control structures Connect exit point of one control structure to entry point of the next (control-structure stacking) Makes programs easy to build

4.4 Control Structures (Cont.) Small circles Solid circle represents the activity’s initial state Solid circle surrounded by a hollow circle represents the activity’s final state Transition arrows Indicate the order in which actions are performed Notes (rectangles with the upper-right corners folded over) Explain the purposes of symbols (like comments in Java) Are connected to the symbols they describe by dotted lines

Fig. 4.1 | Sequence structure activity diagram.

Acknowledgements Deitel, Java How to Program