1️⃣

6.1 Introduction to Boolean Logic

Chapter Table of Contents

🤔
Ch. 6 Conditionals

Section Table of Contents

So a while back, we talked about booleans. Now we will combine that skill with conditionals to really gain control and manipulate our Java programs.

Recall that booleans can only have 2 states: true or false. This is very handy when we need to pick and choose which code to run. For instance, what if I wanted to make a program that printed out whether I could vote depending on what my age is?

I could have a boolean called canVote, which stores whether I can vote or not. To be more specific, I could have a condition like: canVote is true when age is greater than or equal to 18. How do we represent expressions with inequalities? We can use relational operators.

Next Section

2️⃣
6.2 Relational Operators

⚖️

Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License. If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact classes@code4tomorrow.org for inquiries.