Problem : Describe java.lang.Math class methods.
Program :Step 1 - CodingCreate a text file c:\sunilos\TestMath.java and copy below contents./* * Test Math methods */ public class TestMath { public static void main(String[] args) { System.out.println("Math functions"); System.out.println(" Max 2,5 - " + Math.max(2,5)); System.out.println(" Min 2,5 - " + Math.min(2,5)); System.out.println(" Absolute 3.7 - " + Math.abs(3.7)); System.out.println(" Exp 10 - " + Math.exp(10)); System.out.println(" Random Number- " + Math.random()); System.out.println(" Square Root- " + Math.sqrt(4)); } } Step 2 - Deployment
Step 3 - Testing
OutputMath functions Max 2,5 - 5 Min 2,5 - 2 Absolute 3.7 - 3.7 Exp 10 - 22026.465794806718 Random Number- 0.30636837900792924 Square Root- 2.0 FAQWhat is Math class?The classMath contains methods for performing basic
numeric operations such as the elementary exponential, logarithm,
square root, and trigonometric functions.
Important points
<<Previous | Next>> |