Source Code:
- public class MathDemo {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- int a = 10,max;
- int b = 20;
- int c = -15;
- double x = 2,y = 3;
- float z = 8.49f;
- max = Math.max(a, b);
- System.out.printf("max is-%d",max); //Showing maximum value.
- System.out.println("\nmin is -"+Math.min(a, b)); //Showing minimum value.
- System.out.printf("Absolute value is-%d ",Math.abs(c)); //Showing absolute value.
- System.out.println("\n X to the power of Y-: "+Math.pow(x, y));
- System.out.println("round no. id-"+Math.round(z));
- System.out.println("pi = "+Math.PI);
- }
- }
Output:
max is-20min is -10Absolute value is-15X to the power of Y-: 8.0round no. id-8pi = 3.141592653589793
0 comments:
Post a Comment