Posts

Showing posts with the label program to perform all basic arithmetic operations of two numbers.

Java program to perform all basic arithmetic operations of two numbers.

  Java program to perform all basic  arithmetic operations of two numbers.  Program : import java.util.*; public class opera { public static void main(String args[]) { int a,b; int add,sub,mul; float div; Scanner sc=new Scanner( System.in ); System.out.println("Enter any two integer numbers:"); a=sc.nextInt(); b = sc.nextInt(); add=a+b; sub=a-b; mul=a*b; if(b!=0) div=(float)a/b; System.out.println("addition  = " + add); System.out.println("substraction = " + sub); System.out.println("Multiplication = " + mul); System.out.println("Division = " + div); } } Output: Enter any two integer numbers: 10 5 addition  = 15 substraction = 5 Multiplication = 50 Division = 2.0