1 public class BasicOperations{
2
3 public static void main(String args[]) {
4 int tempFirstInt, tempSecondInt, tempResultInt;
5 double tempFirstDouble, tempSecondDouble, tempResultDouble;
6
7 tempFirstInt = 15;
8 tempSecondInt = 4;
9 tempFirstDouble = 1.2;
10 tempSecondDouble = 3.5;
11
12 //Addition
13 tempResultInt= tempFirstInt + tempSecondInt;
14 tempResultDouble= tempFirstDouble + tempSecondDouble;
15 System.out.println(tempFirstInt + " + " + tempSecondInt + " = " + tempResultInt);
16 System.out.println(tempFirstDouble + " + " + tempSecondDouble + " = " + tempResultDouble);
17
18 //Subtraction
19 tempResultInt = tempFirstInt - tempSecondInt;
20 tempResultDouble = tempFirstDouble - tempSecondDouble;
21 System.out.println(tempFirstInt + " - " + tempSecondInt + " = " + tempResultInt);
22 System.out.println(tempFirstDouble + " - " + tempSecondDouble + " = " + tempResultDouble);
23
24 //Mul
25 tempResultInt = tempFirstInt * tempSecondInt;
26 tempResultDouble = tempFirstDouble * tempSecondDouble;
27 System.out.println(tempFirstInt + " * " + tempSecondInt + " = " + tempResultInt);
28 System.out.println(tempFirstDouble + " * " + tempSecondDouble + " = " + tempResultDouble);
29
30 //Division
31 tempResultInt = tempFirstInt / tempSecondInt;
32 tempResultDouble = tempFirstDouble / tempSecondDouble;
33 System.out.println(tempFirstInt + " / " + tempSecondInt + " = " + tempResultInt);
34 System.out.println(tempFirstDouble + " / " + tempSecondDouble + " = " + tempResultDouble);
35
36 //Modulus
37 tempResultInt = tempFirstInt % tempSecondInt;
38 System.out.println(tempFirstInt + " % " + tempSecondInt + " = " + tempResultInt);
39 }
40 }