Video 16(ch4)

Yash
0

 




Program:-

https://drive.google.com/file/d/1bvGGxHzj8xd4J_AMtLO2-ryTqWBZagC4/view?usp=drivesdk



import java.util.Scanner;
public class conditionalsInJava  {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter your age please:");
int age = sc.nextInt();
if(age>=18)
{
    System.out.println("Yes boy you can drive!");
    }
    else{
        System.out.println("No boy you cannot drive yet!");
        }
        
        // we can also write it as follows.
        System.out.println("\nEnter your age again:");
        int age1 = sc.nextInt();
        boolean condition = (age1>=18);
        if(condition)
            {
    System.out.println("Yes boy you can drive!");
    }
    else{
        System.out.println("No boy you cannot drive yet!");
        }
}
}
Tags

Post a Comment

0 Comments
Post a Comment (0)
To Top