Conditional Statements If Else Using Java

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

        int age =19;
        if(age >18){
            System.out.println("you are adult");
        } else {
            System.out.println("you are not adult");
        }
    }
    
}
import java.util.Scanner;
public class age{
    public static void main(String []args){

Scanner sc = new Scanner(System.in);
        System.out.print("enter the your age : ");
        int age = sc.nextInt();
        
        if (age > 18){
            System.out.println("you are adult");

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

        
    }
    

Add a Comment

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