4c – Logical Operations Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.

Slides:



Advertisements
Similar presentations
Computer Science & Engineering 2111 IF and Boolean Functions 1 CSE 2111 Lecture-IF and Boolean Functions.
Advertisements

CS&E 1111 ExIFs IFs and Nested IFs in Excel Objectives: Using the If function in spreadsheets Nesting If functions.
1 CSC103: Introduction to Computer and Programming Lecture No 8.
James Tam Making Decisions In Pascal In this section of notes you will learn how to have your Pascal programs choose between alternative courses of action.
2-1 Making Decisions Sample assignment statements PayAmount = Hours * Rate PayAmount = 40*Rate + (Hours – 40)*Rate*1.5.
Control Structures: Part 2. Introduction Essentials of Counter-Controlled Repetition For / Next Repetition Structure Examples Using the For / Next Structure.
School of Computing Science CMT1000 Ed Currie © Middlesex University 1 CMT1000: Introduction to Programming Ed Currie Lecture 5B: Branch Statements - Making.
Chapter 4: Control Structures: Selection
Programming with MATLAB. Relational Operators The arithmetic operators has precedence over relational operators.
IS 1181 IS 118 Introduction to Development Tools VB Chapter 03.
Vlachopoulos Georgios Lecturer of Computer Science and Informatics Technological Institute of Patras, Department of Optometry, Branch of Egion Lecturer.
Chapter 1: The Foundations: Logic and Proofs
12b. Regression Analysis, Part 2 CSCI N207 Data Analysis Using Spreadsheet Lingma Acheson Department of Computer and Information Science,
12a. Regression Analysis, Part 1 CSCI N207 Data Analysis Using Spreadsheet Lingma Acheson Department of Computer and Information Science,
Selection Structure If... Then.. Else Case. Selection Structure Use to make a decision or comparison and then, based on the result of that decision or.
Dale Roberts Program Control using Java - Boolean Expressions Dale Roberts, Lecturer Computer Science, IUPUI Department of.
CSCI 3328 Object Oriented Programming in C# Chapter 5: C# Control Statement – Part II UTPA – Fall
Problem Solving and Control Statements. Using Exit to Terminate Repetition Statements There are many forms of the Exit statement, designed to terminate.
Logical Operators Jumps Logical Operators The different logical operators found in Java Rational Operators The different rational operators found in Java.
1. We’ve learned that our programs are read by the compiler in order, from top to bottom, just as they are written The order of statement execution is.
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 2) UTPA – Fall 2011 Part of the slides is from Dr. John Abraham’s previous.
5. Database Design Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis Using Spreadsheets 1.
9c. Line Charts CSCI N207 Data Analysis Using Spreadsheet Department of Computer and Information Science, IUPUI Lingma Acheson
1 CSCI N201 Programming Concepts and Database 9 – Loops Lingma Acheson Department of Computer and Information Science, IUPUI.
Conditional Expression One of the most useful tools for processing information in an event procedure is a conditional expression. A conditional expression.
BACS 287 Programming Logic 2. BACS 287 Sequence Construct The sequence construct is the default execution mode for the CPU. The instructions are executed.
6c – Function Procedures Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Introduction to branching.
Introduction to Engineering MATLAB - 13 Agenda Conditional statements  If – end  If – else – end  if – elseif – else - end.
CSCI N201: Programming Concepts Copyright ©2005  Department of Computer & Information Science Working with Selection Structures.
2a. What and Why Database? Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis with Spreadsheets 1.
Chapter 1: The Foundations: Logic and Proofs
9e. Scatter Charts CSCI N207 Data Analysis Using Spreadsheet Department of Computer and Information Science, IUPUI Lingma Acheson
2d – CheckBox Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
2e – RadioButtons Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
7. Data Import Export Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis Using Spreadsheets 1.
Conditional Logic in MATLAB By Bruce Raine. How to do a basic IF – END structure in MATLAB if MATLAB Commands end i.e. do the MATLAB commands if the conditional.
Program Structures Chapter 5. 5 Branching Allows different code to execute based on a conditional test. if, if-else, and switch statements.
2c – Textboxes and Buttons Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
These Guys? Wait, What? Really?  Branching is a fundamental part of programming  It means taking an action based on decision  The decision is dependent.
5b – For Loops Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
Tutorial 4: The Selection Structure 1 Tutorial 4 The Selection Structure.
9d. Pie Charts CSCI N207 Data Analysis Using Spreadsheet Department of Computer and Information Science, IUPUI Lingma Acheson
5a – While Loops Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
Chapter 4 Select … Case Multiple-Selection Statement & Logical Operators 1 © by Pearson Education, Inc. All Rights Reserved. -Edited By Maysoon.
6d – Built-in Procedures Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.-Edited By Maysoon Al-Duwais1.
CPS120 Introduction to Computer Science
Chapter 5- Control Structures: Part 2
Chapter 4 MATLAB Programming
Control Structures: Part 2
Basic Logical Operations (Fascinating)
Chapter 4 Select…Case Multiple-Selection Statement & Logical Operators
Chapter 4 Select…Case Multiple-Selection Statement & Logical Operators
2-1 Making Decisions Sample assignment statements
Making Logical Decisions (IF-THEN-ELSE)
Program Flow Control Selection & repetition
Chapter 4 Select…Case Multiple-Selection Statement & Logical Operators
Problem Solving and Control Statements
Conditional Logic Presentation Name Course Name
Chapter 4 Select…Case Multiple-Selection Statement & Logical Operators
Chapter 4 Select…Case Multiple-Selection Statement & Logical Operators
Programming Concepts and Database
2g – ComboBox Lingma Acheson CSCI N331 VB .NET Programming
Computer Programming Basics
2b – Labels and Pictures Lingma Acheson CSCI N331 VB .NET Programming
Chapter 4 Select…Case Multiple-Selection Statement & Logical Operators
Flow of Control Flow of control is the order in which a program performs actions. Up to this point, the order has been sequential. A branching statement.
4a- If And Else Lingma Acheson CSCI N331 VB .NET Programming
Chapter 4 Select…Case Multiple-Selection Statement & Logical Operators
Presentation transcript:

4c – Logical Operations Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming

Logical Operators AndAlso –Connects two or more conditions –All the conditions have to be true for the compound condition to be true –E.g. ‘Grade will be A if both conditions are satisfied If intFinalScore >= 85 AndAlso strExtra = “Pass” Then strLetterGrade = “A” End If ‘The loan amount will be if the person is a student And income is lower ‘than ‘Otherwise (either a student or low income), the amount will be If strIdentity = “student” AndAlso intIncome < 10000Then intLoanAmount = Else intLoanAmount = End If 2

Logical Operators OrElse –Connects two or more conditions –At least one condition has to be true for the compound condition to be true (also true if more than one condition is true). –E.g. ‘Grade will be A if it meets at least one of the conditions. ‘The grade will be A if either the final score is 90+ or the project score is 95+ ‘The score will still be A if both conditions are met. If intFinalScore >= 90 OrElse intProject >= 95 Then strLetterGrade = “A” End If 3

Logical Operators Xor –Connects two or more conditions –Exclusive OR: Only one condition can be true for the compound condition to be true. –E.g. ‘Grade will be D only if it meets one of the conditions. ‘The grade will be D if either the final score is <60 or the project score is < 60 ‘If both are < 60, the grade will be F. If intFinalScore < 60 Xor intProject < 60 Then strLetterGrade = “D” Else strLetterGrade = “F” End If 4

Logical Operators Xor ‘An example determining discount ‘Either a senior citizen or a VIP member can get 10% discount If strStatus = “senior” Xor strMember = “VIP” Then intDiscount = 10 ‘The above If condition will be false if the person is a senior VIP or neither, thus ‘it will false into the below ElseIf branch ElseIf strMember = “VIP” Then ‘If a senior VIP, will get 20% discount intDiscount = 20 End If 5

Logical Operators Not –Negate the condition. If the condition evaluates to true, negate the condition will make it false, and vise versa. E.g. If Not strStatus = “kids” Then ‘ if status is not kids, get 10% intDiscount = 10 ‘ discount Else ‘ If status is kids, get 20% discount intDiscount = 20 End If 6