Difference between revisions of "Java/C2/Relational-Operations/English"
(Created page with ''''Title of script''': Relational Operators in Java '''Author''': TalentSprint '''Keywords: '''boolean, comparison, relational operator, video tutorial {| style="border-spac…') |
|||
| Line 51: | Line 51: | ||
If not, for relevant tutorials, please visit our | If not, for relevant tutorials, please visit our | ||
| − | website | + | website as shown. |
|- | |- | ||
| Line 63: | Line 63: | ||
| − | A | + | A boolean data type is of size 1 bit |
| Line 109: | Line 109: | ||
'''}''' | '''}''' | ||
| − | | style="border:0.035cm solid #000000;padding:0.097cm;"| | + | | style="border:0.035cm solid #000000;padding:0.097cm;"| Here we have the '''Eclipse IDE '''and the skeleton required for the rest of the code. |
| Line 126: | Line 126: | ||
| − | | style="border:0.035cm solid #000000;padding:0.097cm;"| '''boolean b<nowiki>;</nowiki>''' | + | | style="border:0.035cm solid #000000;padding:0.097cm;"|Type '''boolean b<nowiki>;</nowiki>''' |
| Line 170: | Line 170: | ||
| − | Let us print the value of b. | + | Now Let us print the value of b. |
| Line 184: | Line 184: | ||
|- | |- | ||
| style="border:0.035cm solid #000000;padding:0.176cm;"| Change 45 to 30 | | style="border:0.035cm solid #000000;padding:0.176cm;"| Change 45 to 30 | ||
| − | | style="border:0.035cm solid #000000;padding:0.176cm;"| Let us see what | + | | style="border:0.035cm solid #000000;padding:0.176cm;"| Let us see what happens if the value is less than 40. |
| Line 194: | Line 194: | ||
|- | |- | ||
| style="border:0.035cm solid #000000;padding:0.176cm;"| | | style="border:0.035cm solid #000000;padding:0.176cm;"| | ||
| − | | style="border:0.035cm solid #000000;padding:0.176cm;"| We see that the output is False as expected. | + | | style="border:0.035cm solid #000000;padding:0.176cm;"| We can see that the output is False as expected. |
|- | |- | ||
| Line 210: | Line 210: | ||
'''Save and Run''' | '''Save and Run''' | ||
| − | | style="border:0.035cm solid #000000;padding:0.097cm;"| | + | | style="border:0.035cm solid #000000;padding:0.097cm;"| let us change ''greater than'' to ''less than symbol.'' |
| − | We are checking if the value of '''weight''' is less than '''40'''. | + | So We are checking if the value of '''weight''' is less than '''40'''. |
| − | + | '''Save''' '''Run''' | |
|- | |- | ||
| Line 254: | Line 254: | ||
| − | '''Save''' and '''Run''' | + | '''Save''' and '''Run''' |
|- | |- | ||
| Line 265: | Line 265: | ||
| − | + | ||
| − | Save | + | Save and Run. |
|- | |- | ||
| Line 299: | Line 299: | ||
| − | + | change the double equal to to less than equal to. | |
| Line 306: | Line 306: | ||
|- | |- | ||
| style="border:0.035cm solid #000000;padding:0.097cm;"| Point to output | | style="border:0.035cm solid #000000;padding:0.097cm;"| Point to output | ||
| − | | style="border:0.035cm solid #000000;padding:0.097cm;"| | + | | style="border:0.035cm solid #000000;padding:0.097cm;"| the output is '''True''' as expected. |
| Line 327: | Line 327: | ||
|- | |- | ||
| style="border:0.035cm solid #000000;padding:0.176cm;"| Change 40 to 50. | | style="border:0.035cm solid #000000;padding:0.176cm;"| Change 40 to 50. | ||
| − | | style="border:0.035cm solid #000000;padding:0.176cm;"| | + | | style="border:0.035cm solid #000000;padding:0.176cm;"| Let say 50 |
| − | + | ||
| − | + | ||
Save and Run. | Save and Run. | ||
|- | |- | ||
| style="border:0.035cm solid #000000;padding:0.176cm;"| | | style="border:0.035cm solid #000000;padding:0.176cm;"| | ||
| − | | style="border:0.035cm solid #000000;padding:0.176cm;"| As we can see, the output is False | + | | style="border:0.035cm solid #000000;padding:0.176cm;"| As we can see, the output is False because the value of weight is not equal to 40. |
| Line 386: | Line 384: | ||
| − | '''Save''' and '''Run''' | + | '''Save''' and '''Run''' |
|- | |- | ||
| Line 396: | Line 394: | ||
| style="border:0.035cm solid #000000;padding:0.176cm;"| Let us change the weight to 40 and see the output. | | style="border:0.035cm solid #000000;padding:0.176cm;"| Let us change the weight to 40 and see the output. | ||
| − | Change | + | Change 30to 40. |
Save. Run. | Save. Run. | ||
| Line 419: | Line 417: | ||
'''Summary''' | '''Summary''' | ||
| − | | style="border:0.035cm solid #000000;padding:0.097cm;"| | + | | style="border:0.035cm solid #000000;padding:0.097cm;"| This brings us to the end of this tutorial. |
Latest revision as of 12:47, 8 May 2013
Title of script: Relational Operators in Java
Author: TalentSprint
Keywords: boolean, comparison, relational operator, video tutorial
| Visual Cue | Description |
| Slide 1
Welcome |
Welcome to the spoken tutorial on Relational Operators in Java. |
| Slide 2
Learning Outcomes |
In this tutorial, we will learn about the
|
| Slide 3
Tools Used |
For this tutorial we are using
Ubuntu 11.10, JDK 1.6 and Eclipse 3.7 |
| Slide 4
Prerequisites |
To follow this tutorial, you must have knowledge of data types in Java
website as shown. |
| Slide 5
Boolean data type |
Relational operators are used to check for conditions.
|
| Slide 6
Relational Operators |
Here is a list of the Relational operators available.
We shall look into each of them in detail. |
| Switch to Eclipse. | |
| Minimize Slides and open Eclipse
Eclipse should contain the following code public class BooleanDemo{ public static void main(String[] args){ } } |
Here we have the Eclipse IDE and the skeleton required for the rest of the code.
|
| In the main method, type
boolean b; Highlight boolean b
|
Type boolean b;
|
| In the next line, type
b = weight > 40; System.out.println(b);
|
We shall define a variable weight and check for a condition using that variable.
|
| Point to output | As we can see, the output is True. |
| Change 45 to 30 | Let us see what happens if the value is less than 40.
|
| We can see that the output is False as expected. | |
| Highlight > symbol. | This way, the greater than symbol is used to check if one value is greater than the other.
|
| Change weight > 40 to weight < 40
Highlight the condition.
|
let us change greater than to less than symbol.
So We are checking if the value of weight is less than 40.
Save Run |
| Point to output
Save and Run |
As we can see, the output is True as expected.
|
| We see that we get a False because the condition,
| |
| Change weight < 40 to weight == 40
|
To do that, we use two equal to symbols.
|
| As we can see, the output is False because the value of weight is not equal to 40. | |
| Now let us change the weight to 40 and see the output.
Save and Run. | |
| Point to output
|
As we can see, the output is True
|
| Change weight == 40 to weight <= 40
Save and Run. |
Next we'll see how to check for less than or equal to.
change the double equal to to less than equal to.
|
| Point to output | the output is True as expected.
|
| Change weight = 40 to weight = 30
Save and Run. Point to output |
Change 40 to 30.
Save and Run.
|
| Change 40 to 50. | Let say 50
Save and Run. |
| As we can see, the output is False because the value of weight is not equal to 40.
| |
| Similarly we use a greater than symbol followed by an equal to symbol for checking greater than or equal to.
| |
| Change weight <= 40 to weight >= 40 | Change less than equal to to greater than equal to
|
| Change 45 to 30 | Let us change weight to a value less than 40. Lets say 30.
|
| We get a false because the value of weight is not greater than 40 and also not equal to 40. | |
| Change weight >= 40 to weight != 40
Save and Run.
|
Next, we’ll see how to check for not equal to
|
| Point to output | As we can see, the output is true because the values of weight is not equal to 40. |
| Let us change the weight to 40 and see the output.
Change 30to 40. Save. Run. | |
| We get a false because the condition weight not equal to 40 is false. | |
| The not equal to condition can be thought of as opposite of equal to condition. | |
| This is how we use the various relational operators to compare data in Java. | |
| Minimize the Eclipse window and switch to slides.
Summary |
This brings us to the end of this tutorial.
about the boolean data type The relational operators and how to use relational operators to compare two values |
| Slide 7Assignment
|
As an assignment for this tutorial, find out if the two expressions shown are equivalent? |
Slide 8About the Spoken Tutorial Project
|
To know more about the Spoken Tutorial project,
|
Slide 9Spoken Tutorial WorkshopsThe Spoken Tutorial Project Team
|
The Spoken Tutorial Project Team,
|
Slide 10Acknowledgement
|
Spoken Tutorial Project is a part of the Talk to a Teacher project.
|
Slide 11About the contributor
|
This tutorial has been contributed by TalentSprint. Thanks for joining.
|