else adut codition using java

public class adult {
    public static void main(String []args){

        int n=8;
        int a=18;
         
        if(a<n){
            System.out.println("adult");
            
            
        } else{
            System.out.println("not addult");
        }
    }
    
}
public class adult1 {
    public static void main(String []args){

        int age =20;
        if(age>18){
            System.out.println("adult");
        }else {
            System.out.println("not adult");
        }

    }
    
}

using scanner

import java.util.Scanner;
public class adult2 {
    public static void main(String []args){
        Scanner sc = new Scanner(System.in);
        System.out.println("enter the age: ");
        int age=sc.nextInt();
        if(age>18){
            System.out.println("adult");

        } else{
            System.out.println("not adult");
        }
    }
    
}

Leave a comment

Your email address will not be published. Required fields are marked *