RU beehive logo ITEC dept promo banner
ITEC 109
2014spring
ibarland

homeinfolabsexamshws
D2LMediaSamples/breeze (snow day)tutor/PIs

lab35
if-else statements

Boolean expressions

The type boolean is much simpler than (say) int, because rather than 4+ billion ints, there are only two boolean values: true, and false. Note that these two names aren't variables; they're values, just like 17 and -34 are.

There are some functions in Java which take two numbers, and return a boolean. ==, >, >=, ==, !=, etc.. Type the following boolean expressions into BlueJ's Code Pad:

(2+2 == 4)
2+2 == 5
2+2 != 5
2+2 != 4  // "Is it true, that 2+2 is *not* four?"

5 > 4
5 > 99
5 > 5
5 >= 5

double x = 5;
double y = 43.2;
(x+y)/2 >= Math.sqrt(x*y) // is the arith.avg less than geom.avg., for the current value of x,y?

We will work through the following codingbat problems (some in class, some individually — will not be checked off):

 CodingBat > Python > Warmup-1 > diff21
 CodingBat > Python > Warmup-1 > sum_double
 CodingBat > Python > Warmup-1 > front3
 CodingBat > Python > Warmup-1 > not_string
 
 CodingBat > Python > Warmup-1 > near_hundred
 

homeinfolabsexamshws
D2LMediaSamples/breeze (snow day)tutor/PIs


©2014, Ian Barland, Radford University
Last modified 2014.Apr.09 (Wed)
Please mail any suggestions
(incl. typos, broken links)
to ibarlandradford.edu
Powered by PLT Scheme