Click here to watch in Youtube :
https://www.youtube.com/watch?v=PhEm7Maqqxs&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java Math class (Constants and Basic methods) |
Java Tutorial : Java Math class (Constants and Basic methods) |
public class MathDemo { public static void main(String[] args) { double a = -200.635; double b = 23.74; int c = 46, d = 65; /* * Returns the absolute value of the argument. */ System.out.printf( "The absolute value " + "of %.3f is %.3f%n", a, Math.abs(a)); /* * Returns the smallest integer that is greater than * or equal to the argument. Returned as a double. */ System.out.printf("The ceiling of " + "%.2f is %.0f%n", b, Math.ceil(b)); /* * Returns the largest integer that is less than or * equal to the argument. Returned as a double. */ System.out.printf("The floor of " + "%.2f is %.0f%n", b, Math.floor(b)); /* * Returns the integer that is closest in value to * the argument. Returned as a double. */ System.out.printf("The rint of %.2f " + "is %.0f%n", b, Math.rint(b)); /* * Returns the larger of the two arguments. */ System.out.printf("The max of %d and " + "%d is %d%n", c, d, Math.max(c, d)); /* * Returns the smaller of the two arguments. */ System.out.printf("The min of of %d " + "and %d is %d%n", c, d, Math.min(c, d)); } }
The absolute value of -200.635 is 200.635 The ceiling of 23.74 is 24 The floor of 23.74 is 23 The rint of 23.74 is 24 The max of 46 and 65 is 65 The min of of 46 and 65 is 46
https://sites.google.com/site/javaee4321/java/MathDemo_Basic_Methods_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/MathDemo_Basic_Methods_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/d0559102086f9677d57877fbba43556aca45fc19/BasicJava/MathDemo_Basic_Methods_App/?at=master
See also:
No comments:
Post a Comment