Using the pow & sqrt Function

From Java Example Source Code

Jump to: navigation, search

Contents

[edit] Overview - Using the pow & sqrt Function

This Java example program shows how to use Math.pow & Math.sqrt methods.

[edit] Java Source Code

  • Package: example.math1
  • File: MainClass.java
package example.math1;
 
strictfp class MainClass {
    public static void main(String[] args) {
	// Display the square root of 2 using sqrt()
	System.out.print("sqrt(2.0) = ");
	System.out.println(Math.sqrt(2.0));
	// Calculate and display using pow()
	System.out.print("pow(2.0, 0.5) = ");
	System.out.println(Math.pow(2.0, 0.5));
	System.out.println();
    }
}

[edit] What Result You Can Get

Run the program, you will get:

sqrt(2.0) = 1.4142135623730951
pow(2.0, 0.5) = 1.4142135623730951

[edit] Required External Libraries and/or Files for this Java Example

Need nothing.

http://www.ase2009.com/ online casino 132 http://www.hellzyea.com/health health insurance 8DDD http://www.yourautoinsurancesite.com/ auto insurance quotes 135811 http://www.makemeasammich.com/ auto insurance mcnxu

[edit] Question & Answer

Any question?

Click edit and post your question or answer here.


Personal tools