Wednesday, September 2, 2020

variables in java

 Today we will explain primitive data types , arithmetic operators and variables in java 

 Data types : 

byte, short, int and long data types are used for storing whole numbers.

float and double are used for fractional numbers.

char and string which are used for storing characters(letters).

boolean data type is used for variables that holds either true or false
 
 
 
 
variables :
     variable is a name of reserved area in the computer's memory or it's a name of memory location , an d we have three main types of variables in java 
  • local variables : which are defined inside some method's body
  • instance variables : which are defined out side method body , but in side class body 
  • static variables : which are defined by using "static" word before we defined them , and they can not be defined inside method body
Now :  we can define any variable as bellow 
 
data_type variable_name = value;
 
 
arithmetic operators : 

  
 
 
Now let us go to our example today , and we will explain the code which it's output just as in the image bellow 
 
 
 and the code will be just as 

public class test{
    public static void main(String[]args){
        int num = 10;
        System.out.println("________________________");
        System.out.println();
        System.out.println("      "+num+" * 1 "+" = "+num*1);
        System.out.println("      "+num+" * 2 "+" = "+num*2);
        System.out.println("      "+num+" * 3 "+" = "+num*3);
        System.out.println("      "+num+" * 4 "+" = "+num*4);
        System.out.println("      "+num+" * 5 "+" = "+num*5);
        System.out.println("      "+num+" * 6 "+" = "+num*6);
        System.out.println("      "+num+" * 7 "+" = "+num*7);
        System.out.println("      "+num+" * 8 "+" = "+num*8);
        System.out.println("      "+num+" * 9 "+" = "+num*9);
        System.out.println("      "+num+" * 10 "+" = "+num*10);
        System.out.println("      "+num+" * 11 "+" = "+num*11);
        System.out.println("      "+num+" * 12 "+" = "+num*12);
        System.out.println();
        System.out.println("_________________________");
        System.out.println();
        System.out.println();
        System.out.println();
    }
}

 
Home Work ?
write a java code that give the output in the image bellow 
 

 
 
 

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...