CSC530 Data Structure - Decision

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

Control Statements. Define the way of flow in which the program statements should take place. Control Statements Implement decisions and repetitions.
Pascal Programming Today Chapter 4 1 »Conditional statements allow the execution of one of a number of possible operations. »Conditional statements include:
Introduction to Computers and Programming Lecture 6 Professor: Evan Korth New York University.
Boolean Types & Compound Conditionals CSC 1401: Introduction to Programming with Java Lecture 4 – Part 3 Wanda M. Kunkle.
Boolean Expressions Conditional Statements & Expressions CSC 1401: Introduction to Programming with Java Lecture 4 – Part 2 Wanda M. Kunkle.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Logical and Relational Expressions Nested if statements.
Summer Training on Computer Science, WCU Summer Training on Computer Science Zhen Jiang Department of Computer Science West Chester University.
C++ for Engineers and Scientists Third Edition
Programming with MATLAB. Relational Operators The arithmetic operators has precedence over relational operators.
CHAPTER#3 STRUCTURED PROGRAM DEVELOPMENT IN C++ 1 st semester King Saud University College of Applied studies and Community Service Csc 1101.
Zhen Jiang Dept. of Computer Science West Chester University West Chester, PA CSC141 Computer Science I.
1 Chapter 4: Selection Structures. In this chapter, you will learn about: – Selection criteria – The if-else statement – Nested if statements – The switch.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
Copyright © 2012 Pearson Education, Inc. Chapter 4: Making Decisions.
Flow of Control Part 1: Selection
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 4 Decision.
Summer Training on Computer Science, WCU Summer Training on Computer Science 2008 Zhen Jiang Department of Computer Science West Chester University West.
Decision Making - CIS 1068 Program Design and Abstraction Zhen Jiang CIS Dept. Temple University SERC 347, Main Campus 10/27/20151.
Lecture 3 Decisions (Conditionals). One of the essential features of computer programs is their ability to make decisions. Like a train that changes tracks.
© 2000 Scott S Albert Selection Structures Structured Programming 256 Chapter 4.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
Chapter 4 Making Decision Csc 125 C++ programming language Fall 2005.
Decisions  Relational operators  Operate on two numbers or two Strings  ==, !=, >, >=,
Chapter 7 Selection Dept of Computer Engineering Khon Kaen University.
Programming 1 DCT 1033 Control Structures I (Selection) if selection statement If..else double selection statement Switch multiple selection statement.
CSC115 Introduction to Computer Programming Zhen Jiang Dept. of Computer Science West Chester University West Chester, PA 19383
Control Structures - Selections - Repetitions/iterations (part 2) 1 -Based on slides from Deitel & Associates, Inc. - Revised by T. A. Yang.
Chapter 5 Selection Statements Mr. Dave Clausen La Cañada High School.
CSC115: Matlab Special Session Dr. Zhen Jiang Computer Science Department West Chester University.
More Selection Executing Statements Selectively Chap. 7 (Read § & Part of Picture: Boolean Logic and Digital Design) 1.
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.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
C++ for Engineers and Scientists Second Edition Chapter 4 Selection Structures.
Zhen Jiang Dept. of Computer Science West Chester University West Chester, PA CSC530 Data Structures - LOOP 7/9/20161.
5.04 Apply Decision Making Structures
More on the Selection Structure
Introduction to C++ Programming Language
Decisions Chapter 4.
Chapter 4: Making Decisions.
Selection—Making Decisions
Lecture 3- Decision Structures
Test Review Computer Science History
Chapter 4: Decision Structures and Boolean Logic
Chapter 4: Making Decisions.
CSC115 Introduction to Computer Programming
CSC141 Computer Science I Zhen Jiang Dept. of Computer Science
Control Structures.
CSC115 Introduction to Computer Programming
MIS 3200 – Unit 4 Complex Conditional Statements else if switch.
CSC141 Computer Science I Zhen Jiang Dept. of Computer Science
Loop Development Zhen Jiang Dept. of Computer Science
IF if (condition) { Process… }
CSC115 Introduction to Computer Programming
CSC141 Computer Science I Zhen Jiang Dept. of Computer Science
Control Structures: Selection Statement
Chapter 4: Decision Structures and Boolean Logic
CSC115 Introduction to Computer Programming
Chapter 3: Selection Structures: Making Decisions
Boolean Expressions to Make Comparisons
Topics discussed in this section:
CS2011 Introduction to Programming I Selections (I)
Zhen Jiang West Chester University
Chapter 3: Selection Structures: Making Decisions
Control Structures: Selection Statement
Selection Control Structure
Chapter 4: Decision Structures and Boolean Logic
Chapter 5 Selection Statements
Presentation transcript:

CSC530 Data Structure - Decision Zhen Jiang Dept. of Computer Science West Chester University West Chester, PA 19383 zjiang@wcupa.edu

Selection (Decision) Introduction T/F selection MC selection

Selection (Decision) Rolling a dice. Sample execution (click on this link to try) Each button in the above sample has

No Yes Win/Lost? Double the money Bankrupt Restart

If else statement if (test) action 1 (statements 1) else action 2 (statements 2) //end if action 3 (statement 3)

No Yes Test by boolean expression Action 1 Action 2 Action 3

Boolean expression in test Simple expression Format <Value> <relational operators> <Value> Number value relational operators ==, !=, <, >, <=, >= !!! Number one error: “(a=2)” instead of “(a==2)” char value (not string!) relational operators ==, !=

Complex expression &&, ||, ! Truth table Precedence order Number range

Development of a correct decision program Grade.java

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

If statement Relational operator ? Multiple selection Nested if If else if Example: letter grade

Comments: Nested if for multiple selection problem If case 1 else if … //end of case 2 if //End of case 1 if

Development of a correct multiple-decision program Letter grade

Switch Switch([variable]) Case [constant value]: Break (or no break)