Here is a Program to Perform the Arithmetic Operation between two Variable
Explanation of Arithmetic Operation Java Program
In this program we have two variable a and b which has command line argument value after assigning those value we have performed different operation on Variable which is afterward outputted to console using System.out.println() Method.
public class IntOps { public static void main(String[] args) { /* * Here we have used parstInt method to convert string to integer */ int a = Integer.parseInt(args[0]); int b = Integer.parseInt(args[1]); int sum = a + b; int prod = a * b; int quot = a / b; int rem = a % b; int a = Integer.parseInt(args[0]); int b = Integer.parseInt(args[1]); int sum = a + b; int prod = a * b; int quot = a / b; int rem = a % b; System.out.println(a + " + " + b + " = " + sum); System.out.println(a + " * " + b + " = " + prod); System.out.println(a + " / " + b + " = " + quot); System.out.println(a + " % " + b + " = " + rem); System.out.println(a + " = " + quot + " * " + b + " + " + rem); } } /***************** * Output of Program * * % java IntOps 10 -3 * 10 + -3 = 7 * 10 * -3 = -30 * 10 / -3 = -3 * 10 % -3 = 1 * 10 = -3 * -3 + 1 * **********************/
Explanation of Arithmetic Operation Java Program
In this program we have two variable a and b which has command line argument value after assigning those value we have performed different operation on Variable which is afterward outputted to console using System.out.println() Method.