© a+ computer science - €¦ · that is associated with a condition. the block of code may...
TRANSCRIPT
![Page 1: © A+ Computer Science - €¦ · that is associated with a condition. The block of code may execute . once or not at all depending on . the evaluation of the condition](https://reader035.vdocuments.mx/reader035/viewer/2022081614/5fcb884d2168e056be14d05f/html5/thumbnails/1.jpg)
![Page 2: © A+ Computer Science - €¦ · that is associated with a condition. The block of code may execute . once or not at all depending on . the evaluation of the condition](https://reader035.vdocuments.mx/reader035/viewer/2022081614/5fcb884d2168e056be14d05f/html5/thumbnails/2.jpg)
© A+ Computer Science - www.apluscompsci.com
![Page 3: © A+ Computer Science - €¦ · that is associated with a condition. The block of code may execute . once or not at all depending on . the evaluation of the condition](https://reader035.vdocuments.mx/reader035/viewer/2022081614/5fcb884d2168e056be14d05f/html5/thumbnails/3.jpg)
© A+ Computer Science - www.apluscompsci.com
if I am hungry I eat something if I am tired I go to sleep
![Page 4: © A+ Computer Science - €¦ · that is associated with a condition. The block of code may execute . once or not at all depending on . the evaluation of the condition](https://reader035.vdocuments.mx/reader035/viewer/2022081614/5fcb884d2168e056be14d05f/html5/thumbnails/4.jpg)
© A+ Computer Science - www.apluscompsci.com
if it is dark I turn a light on if I can’t hear the song I make it louder
![Page 5: © A+ Computer Science - €¦ · that is associated with a condition. The block of code may execute . once or not at all depending on . the evaluation of the condition](https://reader035.vdocuments.mx/reader035/viewer/2022081614/5fcb884d2168e056be14d05f/html5/thumbnails/5.jpg)
© A+ Computer Science - www.apluscompsci.com
![Page 6: © A+ Computer Science - €¦ · that is associated with a condition. The block of code may execute . once or not at all depending on . the evaluation of the condition](https://reader035.vdocuments.mx/reader035/viewer/2022081614/5fcb884d2168e056be14d05f/html5/thumbnails/6.jpg)
© A+ Computer Science - www.apluscompsci.com
Relational frequently used operators
Operator Use
x==y checks if x and y have the same value
x>y checks if x is greater than y
x<y checks if x is less than y
x>=y checks if x is greater than or equal to y
x<=y checks if x is less than or equal to y
x!=y checks if x is not equal to y
![Page 7: © A+ Computer Science - €¦ · that is associated with a condition. The block of code may execute . once or not at all depending on . the evaluation of the condition](https://reader035.vdocuments.mx/reader035/viewer/2022081614/5fcb884d2168e056be14d05f/html5/thumbnails/7.jpg)
© A+ Computer Science - www.apluscompsci.com
A boolean is any condition or variable that can be evaluated to true or false. 10 == 10 boolean isOdd = true; boolean isEven = false;
![Page 8: © A+ Computer Science - €¦ · that is associated with a condition. The block of code may execute . once or not at all depending on . the evaluation of the condition](https://reader035.vdocuments.mx/reader035/viewer/2022081614/5fcb884d2168e056be14d05f/html5/thumbnails/8.jpg)
© A+ Computer Science - www.apluscompsci.com
![Page 9: © A+ Computer Science - €¦ · that is associated with a condition. The block of code may execute . once or not at all depending on . the evaluation of the condition](https://reader035.vdocuments.mx/reader035/viewer/2022081614/5fcb884d2168e056be14d05f/html5/thumbnails/9.jpg)
© A+ Computer Science - www.apluscompsci.com
An if statement is a block of code that is associated with a condition. The block of code may execute once or not at all depending on the evaluation of the condition.
![Page 10: © A+ Computer Science - €¦ · that is associated with a condition. The block of code may execute . once or not at all depending on . the evaluation of the condition](https://reader035.vdocuments.mx/reader035/viewer/2022081614/5fcb884d2168e056be14d05f/html5/thumbnails/10.jpg)
© A+ Computer Science - www.apluscompsci.com
if ( boolean condition placed here ) { do something 1; do something 2; }
![Page 11: © A+ Computer Science - €¦ · that is associated with a condition. The block of code may execute . once or not at all depending on . the evaluation of the condition](https://reader035.vdocuments.mx/reader035/viewer/2022081614/5fcb884d2168e056be14d05f/html5/thumbnails/11.jpg)
© A+ Computer Science - www.apluscompsci.com
int aplus = 109; if(aplus<100) { System.out.println("aplus < 100"); } if(aplus>100) { System.out.println("aplus > 100"); }
OUTPUT
aplus > 100
![Page 12: © A+ Computer Science - €¦ · that is associated with a condition. The block of code may execute . once or not at all depending on . the evaluation of the condition](https://reader035.vdocuments.mx/reader035/viewer/2022081614/5fcb884d2168e056be14d05f/html5/thumbnails/12.jpg)
© A+ Computer Science - www.apluscompsci.com
int uilScore = 240; if(uilScore==240) { System.out.println("state champ"); } if(uilScore<100) { System.out.println("work harder"); }
OUTPUT
state champ
![Page 13: © A+ Computer Science - €¦ · that is associated with a condition. The block of code may execute . once or not at all depending on . the evaluation of the condition](https://reader035.vdocuments.mx/reader035/viewer/2022081614/5fcb884d2168e056be14d05f/html5/thumbnails/13.jpg)
© A+ Computer Science - www.apluscompsci.com
String stringOne = "big"; if(stringOne.equals("it")) { System.out.println("== it"); } if(stringOne.equals("big")) { System.out.println("== big"); }
OUTPUT
== big
![Page 14: © A+ Computer Science - €¦ · that is associated with a condition. The block of code may execute . once or not at all depending on . the evaluation of the condition](https://reader035.vdocuments.mx/reader035/viewer/2022081614/5fcb884d2168e056be14d05f/html5/thumbnails/14.jpg)
© A+ Computer Science - www.apluscompsci.com
boolean isOdd = true; if(isOdd == true) { System.out.println("isodd"); } if(isOdd == false) { System.out.println("iseven"); }
OUTPUT
isodd
![Page 15: © A+ Computer Science - €¦ · that is associated with a condition. The block of code may execute . once or not at all depending on . the evaluation of the condition](https://reader035.vdocuments.mx/reader035/viewer/2022081614/5fcb884d2168e056be14d05f/html5/thumbnails/15.jpg)
![Page 16: © A+ Computer Science - €¦ · that is associated with a condition. The block of code may execute . once or not at all depending on . the evaluation of the condition](https://reader035.vdocuments.mx/reader035/viewer/2022081614/5fcb884d2168e056be14d05f/html5/thumbnails/16.jpg)
![Page 17: © A+ Computer Science - €¦ · that is associated with a condition. The block of code may execute . once or not at all depending on . the evaluation of the condition](https://reader035.vdocuments.mx/reader035/viewer/2022081614/5fcb884d2168e056be14d05f/html5/thumbnails/17.jpg)
![Page 18: © A+ Computer Science - €¦ · that is associated with a condition. The block of code may execute . once or not at all depending on . the evaluation of the condition](https://reader035.vdocuments.mx/reader035/viewer/2022081614/5fcb884d2168e056be14d05f/html5/thumbnails/18.jpg)
© A+ Computer Science - www.apluscompsci.com
int num=7; if(num>2) { if(num<10) System.out.println(">2<10"); if(num>10) System.out.println(">2>10"); }
OUTPUT
>2<10
![Page 19: © A+ Computer Science - €¦ · that is associated with a condition. The block of code may execute . once or not at all depending on . the evaluation of the condition](https://reader035.vdocuments.mx/reader035/viewer/2022081614/5fcb884d2168e056be14d05f/html5/thumbnails/19.jpg)
![Page 20: © A+ Computer Science - €¦ · that is associated with a condition. The block of code may execute . once or not at all depending on . the evaluation of the condition](https://reader035.vdocuments.mx/reader035/viewer/2022081614/5fcb884d2168e056be14d05f/html5/thumbnails/20.jpg)
© A+ Computer Science - www.apluscompsci.com
If(total >= 25); { } if(total = 10) { }
![Page 21: © A+ Computer Science - €¦ · that is associated with a condition. The block of code may execute . once or not at all depending on . the evaluation of the condition](https://reader035.vdocuments.mx/reader035/viewer/2022081614/5fcb884d2168e056be14d05f/html5/thumbnails/21.jpg)
© A+ Computer Science - www.apluscompsci.com
Never put a ; before an open { brace ;{ }; legal
illegal
![Page 22: © A+ Computer Science - €¦ · that is associated with a condition. The block of code may execute . once or not at all depending on . the evaluation of the condition](https://reader035.vdocuments.mx/reader035/viewer/2022081614/5fcb884d2168e056be14d05f/html5/thumbnails/22.jpg)
© A+ Computer Science - www.apluscompsci.com
![Page 23: © A+ Computer Science - €¦ · that is associated with a condition. The block of code may execute . once or not at all depending on . the evaluation of the condition](https://reader035.vdocuments.mx/reader035/viewer/2022081614/5fcb884d2168e056be14d05f/html5/thumbnails/23.jpg)