Programming Log - Day 3 - 29/06/2018 - s9f10 - Java Basics - if and else , logical operators

in programming •  6 years ago 


//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:

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order: