Lec: 7 JAVA
LEC:7
Operators in JAVA
Source Code:
package lec_5;
import java.util.*;
public class Lec_5 {
public static void main(String[] args) {
// Scanner O1=new Scanner(System.in);
// System.out.println("Enter your name");
// String name=O1.nextLine();
// System.out.println("Name is by using nextline()"+name);
// String name1=O1.next();
// System.out.println("Name is by using nextline()"+name1);
//Arthmetic operators in java
//Subtraction of two numbers.
// System.out.println("Enter first Number : ");
// Scanner O1=new Scanner(System.in);
// int x=O1.nextInt();
// System.out.println("Enter Second Number : ");
// int y=O1.nextInt();
// int add=x-y;//oprators--> + ,operands --->x and y
// System.out.println("Subtraction of "+ x+ " and "+y+" is : "+add);
//Increment opreators (++)
// int var1=90;
// System.out.println("the value of Var1 is : "+var1);
// var1++;
// System.out.println("After incrementation the value of Var1 is : "+var1);
//Decrement opreators (++)
// int var2=90;
// System.out.println("the value of Var2 is : "+var2);
// var2--;
// System.out.println("After Decrementation the value of Var2 is : "+var2);
Scanner O1=new Scanner(System.in);
System.out.println("Enter first number");
int a=O1.nextInt();
System.out.println("Enter Second number");
int b=O1.nextInt();
//Assignment operators
//1) +=
//a=a+b;
//a+=b;//a=6,b=8; a=14
// System.out.println("the additiion of a-b is : " + a);
//Logical operators
if(a==b)
{
System.out.println("yes a is equals to b");
}
else
System.out.println("yes b is not equal to a");
}
}
Comments
Post a Comment