JAVA Program
Static
Write a Java program to enter two numbers and perform all arithmetic operations.
Sol :-
class arithmetic
{
public static void main(String args[])
{
int a=10,b=20;
int add = a+b;
int sub = a-b;
int mul = a*b;
int div = a/b;
int mod = a%b;
System.out.println("The sum of two number is :-"+add);
System.out.println("The sub of two number is :-"+sub);
System.out.println("The mul of two number is :-"+mul);
System.out.println("The div of two number is :-"+div);
System.out.println("The mod of two number is :-"+mod);
}
}
Output :-
import java.util.*;
class arithmetic
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("Enter the first number :- ");
int a = in.nextInt();
System.out.println("Enter the Second number :- ");
int b = in.nextInt();
int add = a+b;
int sub = a-b;
int mul = a*b;
int div = a/b;
int mod = a%b;
System.out.println("The sum of two number is :-"+add);
System.out.println("The sub of two number is :-"+sub);
System.out.println("The mul of two number is :-"+mul);
System.out.println("The div of two number is :-"+div);
System.out.println("The mod of two number is :-"+mod);
}
}
Output :-