Calculation

Java Programming

Java Programming Examples

import java.io.*;

class calculation {
	public static void main(String args[ ]) {
		int sum, sub, mul, div, mod;
		System.out.println("Calculation in Java");

		/* Calculation of Sum */
		sum = 1 + 2;

		/* Calculation of Subtract */
		sub = 3 - 2;

		/* Calculation of Multiplication */
		mul = 2 * 2;

		/* Calculation of Division */
		div = 4 / 2;

		/* Calculation of Modulus */
		mod = 3 % 2;
		System.out.println("Sum: "+sum);
		System.out.println("Subtract: "+sub);
		System.out.println("Multiplication: "+mul);
		System.out.println("Division: "+div);
		System.out.println("Modulus: "+mod);
	}
}


          /****** Output ******/
          

Calculation in Java


Sum: 3


Subtract: 1


Multiplication: 4


Division: 2


Modulus: 1