Tuesday, September 8, 2020

Conditions statements in java

JAVA

Today we will explain the conditions statements & scope in Java 

conditions statements

we can test conditions in java by using "if statement" which has many ways to use 

  •  if-statement
  •  is-else statement
  • nested if statement 
 and we can use the diagram bellow to explain the way of it's work 
 
 
 

Scope  

 refers to the lifetime and accessibility of a variable. How large the scope is depends on where a variable is declared
 
Now : let us explain all of these by create a java program in which we create a variable "integer" , and give it any value we want , then we will test if this value is less than 10 , print "small number", if it's  as grater than 100, print "large number", and if it's between 10 and 100 or equal to 100 , print "accepted"  in the image bellow 
 
 
the code will be just as  :
 
public class test{
    public static void main(String[]args){
        int num = 200;
        if (num <10) {
            System.out.println("__ small number ____");
        }
        if (num >100) {
            System.out.println("__ large number ____");
        }
        if (num >10 && num <=100) {
            System.out.println("__ accepted ____");
        }
        System.out.println("________________________");
    }
}



No comments:

Post a Comment

Odoo Invoice Qr code issues

There are two main issues must of us facing with the QR code in Odoo invoice & these issues are 1/ QR code displayed as broken image w...