CSC115 Introduction to Computer Programming Zhen Jiang Dept. of Computer Science West Chester University West Chester, PA 19383

Slides:



Advertisements
Similar presentations
Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
Advertisements

Chapter 4 Decision Making Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E. Reingold.
Programming with App Inventor Computing Institute for K-12 Teachers Summer 2012 Workshop.
Control Statements. Define the way of flow in which the program statements should take place. Control Statements Implement decisions and repetitions.
CSE 1301 Lecture 5B Conditionals & Boolean Expressions Figures from Lewis, “C# Software Solutions”, Addison Wesley Briana B. Morrison.
Pascal Programming Today Chapter 4 1 »Conditional statements allow the execution of one of a number of possible operations. »Conditional statements include:
1 CSC103: Introduction to Computer and Programming Lecture No 8.
Decisions (Conditional Programming) Chapter 5 (Sec. 5.1 & 5.2)
Boolean Expressions Conditional Statements & Expressions CSC 1401: Introduction to Programming with Java Lecture 4 – Part 2 Wanda M. Kunkle.
Control Structures: Part 2. Introduction Essentials of Counter-Controlled Repetition For / Next Repetition Structure Examples Using the For / Next Structure.
The If/Else Statement, Boolean Flags, and Menus Page 180
C++ for Engineers and Scientists Third Edition
Programming with MATLAB. Relational Operators The arithmetic operators has precedence over relational operators.
Zhen Jiang Dept. of Computer Science West Chester University West Chester, PA CSC141 Computer Science I.
CS0004: Introduction to Programming Relational Operators, Logical Operators, and If Statements.
08/10/ Iteration Loops For … To … Next. 208/10/2015 Learning Objectives Define a program loop. State when a loop will end. State when the For.
CHAPTER 4: CONDITIONAL STRUCTURES Introduction to Computer Science Using Ruby (c) 2012 Ophir Frieder et al.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
PAGES:51-59 SECTION: CONTROL1 : DECISIONS Decisions.
1 Nassau Community CollegeProf. Vincent Costa Acknowledgements: An Introduction to Programming Using Visual Basic 2012, All Rights ReservedAn Introduction.
Flow of Control Part 1: Selection
CMPS 1371 Introduction to Computing for Engineers CONDITIONAL STATEMENTS.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 4 Decision.
Decision Making - CIS 1068 Program Design and Abstraction Zhen Jiang CIS Dept. Temple University SERC 347, Main Campus 10/27/20151.
1 Boolean Expressions to Make Comparisons Boolean expression –Represents only one of two states –Expression evaluates to either true or false Expressions.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
Conditional Statement Chapter 8. Conditional Statements Are statements that check an expression then may or may not execute a statement or group of statement.
Decisions  Relational operators  Operate on two numbers or two Strings  ==, !=, >, >=,
© ABB University - 1 Revision C E x t e n d e d A u t o m a t i o n S y s t e m x A Chapter 11 Structured Text Course T314.
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Introduction to branching.
CSC115: Matlab Special Session Dr. Zhen Jiang Computer Science Department West Chester University.
Copyright 2008 by Pearson Education Building Java Programs Chapter 4 Lecture 4-1: if and if/else Statements reading: 4.2 self-check: #4-5, 7, 10, 11 exercises:
Higher Computing Software Development -So Far- 5/10/10.
Zhen Jiang Dept. of Computer Science West Chester University West Chester, PA CSC141 Computer Science I 2/4/20161.
Midterm Exam Topics (Prof. Chang's section) CMSC 201.
Visual Basic Review LBS 126. VB programming Project Form 1Form 2Form 3 Text boxButton Picture box Objects Text box Button Objects.
Chapter 5 – Decision Making. Structured Programming Sequence Selection Repetition yesno yes no.
Zhen Jiang Dept. of Computer Science West Chester University West Chester, PA CSC141 Computer Science I.
Control Structure  What is control Structure?  Types of Controls  Use the control structure in VBScript.  Example Summery.
Computer Science Up Down Controls, Decisions and Random Numbers.
TUTORIAL 4 Visual Basic 6.0 Mr. Crone. Pseudocode Pseudocode is written language that is part-code part- English and helps a programmer to plan the layout.
Zhen Jiang Dept. of Computer Science West Chester University West Chester, PA CSC530 Data Structures - LOOP 7/9/20161.
UNIT 5 Lesson 15 Looping.
Chapter 4: Making Decisions.
Oracle11g: PL/SQL Programming Chapter 2 Basic PL/SQL Block Structures.
Lecture 3- Decision Structures
The Selection Structure
Factoring if/else code
Chapter 4: Decision Structures and Boolean Logic
CSC115 Introduction to Computer Programming
CSC141 Computer Science I Zhen Jiang Dept. of Computer Science
Control Structures.
CSC115 Introduction to Computer Programming
Loop Development Zhen Jiang Dept. of Computer Science
Making Decisions in a Program
CSC115 Introduction to Computer Programming
CSC141 Computer Science I Zhen Jiang Dept. of Computer Science
CSC530 Data Structure - Decision
Types, Truth, and Expressions (Part 2)
Control Structures: Selection Statement
Chapter 4: Decision Structures and Boolean Logic
Microsoft Visual Basic 2005: Reloaded Second Edition
CSC115 Introduction to Computer Programming
Boolean Expressions to Make Comparisons
Control Structures: Selection Statement
Chapter 4: Decision Structures and Boolean Logic
Lecture 9: Implementing Complex Logic
Control Structures.
Types, Truth, and Expressions (Part 2)
Presentation transcript:

CSC115 Introduction to Computer Programming Zhen Jiang Dept. of Computer Science West Chester University West Chester, PA

Table of Contents Structure Selection (Decision) Loop Array and Function

Price is right. Sample execution (click on this link to try)this link Selection (Decision)

Condition Yes Action 1Action 2 No Action 3

Boolean Expression Yes Action 1 If controlled Action 2 else controlled No Action 3 11/21/20155

If block if condition then action 1 (statements 1) else action 2 (statements 2) end if action 3 (statement 3)

Legal age to have driver’s license

Condition Simple condition Format Number value relational operators =, <>,, = String value relational operators =, <> Complex condition And, or, not Truth table, table 4, p121

Relational operators have lower precedence than math operators. 5 * 7 >= * (7 - 1)‏ 5 * 7 >= * 6 35 >= >= 33 true Relational operators cannot be chained (unlike math operators) 2 <= x <= 10 error! 11/21/201510

Identify two exclusive options Implement each handling in different action parts Identify the situation (values) for option selection Make a condition so that all the situation value for option part 1 will lead to this condition true. Verify all the situation value for option part 2 will lead to this condition false, otherwise, revise the above condition! Development Process

Multiple selection Nested if block Example: letter grade

Comments: Nested if block for multiple section problem If then case 1 Else if then case 2 else … end if End if

If block, extension without else if condition then action 1 (statements 1) end if action 3 (statement 3)

Dim x as integer, y as integer x = text1.text y=0 if x > 3 then y =1 if x >10 then y = 2 else y = 3 End if Listbox1.Items.Add( y ) Try 2 Dim x as integer, y as integer x = text1.text y=0 if x > 3 then y =1 if x > 10 then y = 2 End if else y = 3 End if Listbox1.Items.Add( y )

Dim x as integer, y as integer x = text1.text y=0 if x > 3 then y =1 if x >10 then y = 2 else y = 3 End if Listbox1.Items.Add( y ) Dim x as integer, y as integer x = text1.text y=0 if x > 3 then y =1 if x > 10 then y = 2 End if else y = 3 End if Listbox1.Items.Add( y )

Select block Select case A constant A variable An expression Is To range Else And and or

Loop Do while Loop do while condition statements loop statements2

Yes statements1Action 2 No Action 3 condition

Yes Statements1 No Statements2 condition

Other loops

Clock

Function and procedure

Array