homepages.neiu.eduhomepages.neiu.edu/.../cs200/conceptguide04-selections.docx · web viewassignment...

11
Concept Guide: Decision Structure - Branching Course: CS 200 Introduction to Java Programming, Comprehensive Version, 11 th ed. Text Chapter: 3 Selections Concept/ Topic: Text Notes: Lecture Notes: Logic Operators and Compound Logic Statements (see table included) Boolean data type Using Boolean Data Type: Assignment and Comparing Value Vs. Direct Use How can a user enter a Boolean? coding literals: true false Short- circuit/ Lazy Evaluation Vs. Complete Evaluation

Upload: others

Post on 15-Mar-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: homepages.neiu.eduhomepages.neiu.edu/.../cs200/ConceptGuide04-Selections.docx · Web viewAssignment and Comparing Value Vs. Direct Use How can a user enter a Boolean? coding literals:

Concept Guide: Decision Structure - Branching Course: CS 200Introduction to Java Programming, Comprehensive Version, 11th ed. Text Chapter: 3 Selections

Concept/Topic: Text Notes: Lecture Notes:Logic OperatorsandCompound Logic Statements

(see table included)

Boolean data type

Using Boolean Data Type:Assignment andComparing ValueVs.Direct UseHow can a user enter a Boolean?

coding literals:truefalse

Short-circuit/Lazy EvaluationVs.CompleteEvaluation

What is a decision structure?

Page 2: homepages.neiu.eduhomepages.neiu.edu/.../cs200/ConceptGuide04-Selections.docx · Web viewAssignment and Comparing Value Vs. Direct Use How can a user enter a Boolean? coding literals:

if statement flow structure

if statementsyntax

Page 3: homepages.neiu.eduhomepages.neiu.edu/.../cs200/ConceptGuide04-Selections.docx · Web viewAssignment and Comparing Value Vs. Direct Use How can a user enter a Boolean? coding literals:

if-else statement flow structure

if-else statementsyntax

Page 4: homepages.neiu.eduhomepages.neiu.edu/.../cs200/ConceptGuide04-Selections.docx · Web viewAssignment and Comparing Value Vs. Direct Use How can a user enter a Boolean? coding literals:

Lab Time!

The nested if statement flow structure

nested if statementsyntax

Page 5: homepages.neiu.eduhomepages.neiu.edu/.../cs200/ConceptGuide04-Selections.docx · Web viewAssignment and Comparing Value Vs. Direct Use How can a user enter a Boolean? coding literals:

The if-else if - else statement flow structure

if-else if - else statementsyntax

Lab Time! Use Lab Doc 02Modify the code to place the grade of ‘A’ message in the first if statement.Also validate data to be in the range of 0-100 inclusive

Page 6: homepages.neiu.eduhomepages.neiu.edu/.../cs200/ConceptGuide04-Selections.docx · Web viewAssignment and Comparing Value Vs. Direct Use How can a user enter a Boolean? coding literals:

Comparing String Objects

Conditional Operator

(see sample code)

Decision structures:binary decisionVs.Multiple choice decision

A case for the switch/case

(see table included)

Page 7: homepages.neiu.eduhomepages.neiu.edu/.../cs200/ConceptGuide04-Selections.docx · Web viewAssignment and Comparing Value Vs. Direct Use How can a user enter a Boolean? coding literals:

flowchartingif-else if – elseVs.switch/case

controlling expression

the case label

the break statement

the default statement

Page 8: homepages.neiu.eduhomepages.neiu.edu/.../cs200/ConceptGuide04-Selections.docx · Web viewAssignment and Comparing Value Vs. Direct Use How can a user enter a Boolean? coding literals:

switch/case syntax

int input= 3; //input should be entered from userswitch (input){

case 1: //commands for billing

break;case 2:case 3:

//commands for TechSupport & change passwordbreak;

case 4:default: //both incorrect selection and customer

//service takes you to //someone to help you.

}

Lab Time!

Page 9: homepages.neiu.eduhomepages.neiu.edu/.../cs200/ConceptGuide04-Selections.docx · Web viewAssignment and Comparing Value Vs. Direct Use How can a user enter a Boolean? coding literals: