Given below is the code of java program that adds,subtracts, multiplies and divides two numbers which are entered by the user
import java.util.Scanner;
class Operators
{
public static void main(String args[])
{
int a, b, c, d, e, f;
System.out.println("Enter two integers to calculate their sum ");
Scanner in = new Scanner(System.in);
a = in.nextInt();
b = in.nextInt();
c = a + b;
d = a - b;
e = a * b;
f = a/b;
System.out.println("Sum of entered integers = "+c);
System.out.println("Subtraction of entered integers = "+d);
System.out.println("Multiplication of entered integers = "+e);
System.out.println("Division of entered integers = "+f);
}
}
Any More Questions? Please leave your comments.
Post a Comment