35 LOGICAL "AND" OPERATOR

AND--------> BOTH STATEMENT TRUE OTHERWISE FALSE


 package com.cnc;

public class Main {
public static void main(String[] args) {
int topScore = 100;
if (topScore == 100) {
System.out.println("You got the Highest Score for 1st test");
}
int topScoreNot = 100;
if (topScoreNot != 100) {
System.out.println("You got the Highest Score foe 2nd test");
}
int topScoreGreaterThan = 100;
if (topScoreGreaterThan >= 99) {
System.out.println("You got the Highest Score for 3rd test");
}
int topScoreLessThan = 77;
if (topScoreLessThan <= 100) {
System.out.println("You Score is less than 100 in 4th test");
}
int secondTopScore = 77;
if(
(topScore > secondTopScore) && (topScoreLessThan < 100)){ //&&---> true when both the condition are true
System.out.println("Greater than second top score and less than 100");
}


}
}

OUTCOME

You got the Highest Score for 1st test
You got the Highest Score for 3rd test
You Score is less than 100 in 4th test
Greater than second top score and less than 100

Popular posts from this blog

NUMBER PALINDROME CHALLENGE

ENCAPSULATION CHALLENGE

LARGEST PRIME FACTOR OF A NUMBER