//if and else statements and rational operators
package ifandelseStatements;
import java.util.Scanner;
public class main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter a number:");
int i = input.nextInt();
if(i == 1)
{
System.out.println("ONE");
}
else if(i == 2)
{
System.out.println("TWO");
}
else if(i == 3)
{
System.out.println("THREE");
}
}
}
Result:
// logical operators "and" and "or"
package logicaloperators;
public class main {
public static void main(String[] args) {
int subject1 = 20 ;
int subject2 = 60 ;
if(subject1 > 15 && subject2 > 45)
{
System.out.println("the statement is true");
}
else
{
System.out.Println("the statement is false");
}
}
}
Result:
@originalworks
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit