-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava Boolean Comparisons
More file actions
43 lines (35 loc) · 1.18 KB
/
Copy pathJava Boolean Comparisons
File metadata and controls
43 lines (35 loc) · 1.18 KB
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
//written in Java
public class GreaterLessThan {
public static void main(String[] args) {
double creditsEarned = 176.5;
double creditsOfSeminar = 8;
double creditsToGraduate = 180;
boolean canGraduate = creditsEarned > creditsToGraduate;
System.out.println(canGraduate);
double creditsAfterSeminar = creditsEarned + creditsOfSeminar;
boolean isGreater = creditsToGraduate < creditsAfterSeminar;
System.out.println(isGreater);
}
}
//Equal Comparisons
public class EqualNotEqual {
public static void main(String[] args) {
int songsA = 9;
int songsB = 9;
int albumLengthA = 41;
int albumLengthB = 53;
boolean sameNumberOfSongs = songsA == songsB;
boolean differentLength = albumLengthA != albumLengthB;
}
}
//Greater than or Equal to
public class GreaterThanEqualTo {
public static void main(String[] args){
double recommendedWaterIntake = 8;
double daysInChallenge = 30;
double yourWaterIntake = 235.5;
double totalRecommendedAmount = recommendedWaterIntake * daysInChallenge;
boolean isChallengeComplete = yourWaterIntake >= totalRecommendedAmount;
System.out.println(isChallengeComplete);
}
}