Java
Java
Java Input
a. Scanner Class- to get user input
b. Collecting Information
c. Full Name Focus
Scanner Initialization
Scanner input = new Scanner(System.in);
Reading Input
String fullName = input.nextLine();
Displaying Output
System.out.println(“Your full name is: “ + fullName);
if(condition){
// code to execute if condition is true
}
Syntax
int number= 5;
if (number % 2 == 0) {
System.out.println(“Even”);
}else(
System.out.println(“Odd”);
}
Looping Statement- to execute a block of code repeatedly until a condition is false
Comparison Operator
= equal to
≠ not equal to
> greater than
< less than
>= greater than or equal to
<= less than or equal to
Logical Operator
&& AND: both conditions must be true
|| OR: at least one condition must be true
! NOT: Reverses the boolean state of a condition
Unary Operators
+ Unary plus (No effect on positive numbers)
- Unary Minus (negates the value
++ Increment (increases value by 1)
-- Decrement (decreases value by 1)