Friday, February 8, 2013

Week-3: 3.1: IF statement

If:
The programming you're doing now is sequential programming, meaning the code is
executed from top to bottom. It's very linear, in that each and every line of code will be
read, starting with the first line of code you write and ending at the last line.

But you don't always want your programmes to work like that. Often, you want code to
be executed only if certain conditions are met. For example, you might want one message
to display if a user is below the age of 18 and a different message if he or she is 18 or
older. You want to control the flow of the programme for yourself. You can do this with
conditional logic.

Conditional logic is mainly about the IF word: IF user is less than 18 then display this
message; IF user is 18 or older then display that message. Fortunately, it's very easy to
use conditional logic in Java. Let's start with IF Statements.

Visit for Details


2 comments:

  1. Mohammad Ashraful Hasan Sobuj
    My Batch- 46th
    My Department :CSE
    My ID 201420656

    package conditionallogic;
    public class IFStatements
    }
    public static void main(string[] args)
    {
    int user = 18;
    if (user <= 18)
    {
    System.out.println("User is 18 or younger");
    }
    if (user > 18)
    {
    System.out.println("User is older than 18");
    }
    }

    ReplyDelete
  2. MD : Rashed Prodhania
    Batch : 46th
    Id : 201420763
    package conditionallogic;
    public class IFStatements
    }
    public static void main(string[] args)
    {
    int user = 18;
    if (user != 18)
    {
    System.out.println("User are not permited");

    }
    }

    ReplyDelete