-
-
Save krystian-booker/9021a0a992fd98c90216f18d7e6fed27 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Week2Task2 { | |
public static void main(String[] args) { | |
// Declare two integer variables and assign them values | |
int a = 10; | |
int b = 20; | |
// Use arithmetic operators | |
int sum = a + b; | |
int difference = a - b; | |
int product = a * b; | |
int quotient = b / a; | |
int remainder = b % a; | |
System.out.println("Sum: " + sum); | |
System.out.println("Difference: " + difference); | |
System.out.println("Product: " + product); | |
System.out.println("Quotient: " + quotient); | |
System.out.println("Remainder: " + remainder); | |
// Use relational operators | |
boolean isEqual = (a == b); | |
boolean isNotEqual = (a != b); | |
boolean isGreater = (a > b); | |
boolean isLesser = (a < b); | |
System.out.println("Is a equal to b? : " + isEqual); | |
System.out.println("Is a not equal to b? : " + isNotEqual); | |
System.out.println("Is a greater than b? : " + isGreater); | |
System.out.println("Is a less than b? : " + isLesser); | |
// Use logical operators | |
boolean andResult = (a > 5) && (b > 5); | |
boolean orResult = (a > 25) || (b > 25); | |
boolean notResult = !(a == b); | |
System.out.println("Both a and b greater than 5? : " + andResult); | |
System.out.println("Either a or b greater than 25? : " + orResult); | |
System.out.println("Is it not the case that a and b are equal? : " + notResult); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment