Computer Science 1026 Topic 8.docx

2 Pages
179 Views
Unlock Document

Department
Computer Science
Course
Computer Science 1026A/B
Professor
Brian Langen
Semester
Fall

Description
Topic 8: More on While Loops While Loop - Review  General Syntax: o While (test) { Body of Loop }  Test: o A Boolean with condition(s) that equate to true or false o Occurs before the body of the loop runs  Body of the Loop: o Statements to be executed while the conditions is true o Something within the body of the loop must change to change the result of the condition Relational Operators  Relational Operators: o Greater than: > o Less than: < o Equal: == o Not equal: != o Greater than or equal: >= o Less than or equal: <=  Expresses a Boolean type condition that evaluates to true or false  When more than one condition needs to be tested, relational operators can be combined with logical operators Logical Operators  AND Operator (&&): o Checks if several conditions are true. o Expression evaluates to true only when every condition in the statement is true. o Use to check whether a value is within a range o Short Circuiting: Evaluation stops, and equates to false if the first condition turns out to be false.  Since all conditions need to be true, it is unnecessary to continue if one condition is false o Ex. (x > 0) && (x < 100)  OR Operator (||): o Checks if at least one of several conditions are true. o Expression evaluates to true if at least one condition in the statement is true. o Short Circuiting: Evaluation stops, and equates to true if the first condition turns out to be true.  Since only one condition needs to be true, it is unnecessary to continue if one condition is true  True / False Table for && and || in Java A
More Less

Related notes for Computer Science 1026A/B

Log In


OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.


Submit