A java program to perform simple arithmetic using constants with +,-,* and / operators
public class Arithmetic {
public static void main(String[] args) {
int n1=10,n2=10,sum,diff,mul,div;
sum=n1+n2;
System.out.println("The sum of "+ n1 +" & "+n2+" is " +sum);
diff=n1-n2;
System.out.println("The Difference of "+ n1 +" & "+n2+" is " +diff);
mul=n1*n2;
System.out.println("The Product of "+ n1 +" & "+n2+" is " +mul);
div=n1/n2;
System.out.println("The Division of "+ n1 +" & "+n2+" is " +diff);
}
}
The sample output will be:
The sum of 10 & 10 is 20
The Difference of 10 & 10 is 0
The Product of 10 & 10 is 100
The Division of 10 & 10 is 1