This repository has been archived by the owner on Nov 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
additionalExample.java
60 lines (52 loc) · 1.46 KB
/
additionalExample.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
Lesson _02
In this lesson we will learn more a about conditional statements
In this example we will be covering more about relational and logical operators
*/
/*
* @author Surya
*/
public class additionalExample
{
public static void main(String[]args)
{
boolean happy = false;
boolean sad = true;
boolean leftMotorIsWorking = true;
boolean rightMotorIsWorking = true;
if(happy)
{
System.out.println("You are happy.");
}
//Another way of say if(happy) is if(happy == true)
if(!happy)
{
System.out.println("You are not happy. :(");
}
//Another way of say if(!happy) is if(happy == false)
if(happy != sad)
{
if(happy && !sad) //Another way of saying if(happy && !sad) is if(happy == true && sad == false)
{
System.out.println("You are happy. You should feel proud.");
}
if(!happy && sad) //Another way of saying if(!happy && sad) is if(happy == false && sad == true)
{
System.out.println("You are sad. I feel bad for you.");
}
}
if(happy == sad)
{
System.out.println("Your emotions make no sense");
}
if(leftMotorIsWorking || rightMotorIsWorking)
{
System.out.println("One of the motors is working. Maybe even both are working");
}
if(!leftMotorIsWorking || !rightMotorIsWorking)
{
System.out.println("One of the motors is not working .Maybe even both aren't working");
}
}
// else statements wer'nt used for the sake of learning about relational and logical operators
}