Write a Java Program to enter two integer number from the user and perform addition, substraction, division,multiplication and modules.

Q.5 Write a Java Program to enter two integer number from the user and perform addition, substraction, division,multiplication and modules.

Solution :- 

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

Leave a Reply

Your email address will not be published. Required fields are marked *

sign up!

We’ll send you the hottest deals straight to your inbox so you’re always in on the best-kept software secrets.