Convert between Polar and Rectangular Coordinates

From Java Example Source Code

Jump to: navigation, search

Contents

[edit] Overview - Convert between Polar and Rectangular Coordinates

This is a Java example program.

[edit] Java Source Code

  • Package: example.math
  • File: MainClass.java
package example.math;
 
strictfp class MainClass {
    public static void main(String[] args) {
	double num, loge, log10, aloge, alog10;
 
	// Obtain input from user
	num = 0.111d;
 
	// Calculate and display the natural logarithm
	loge = Math.log(num);
	System.out.println("log base e = " + loge);
	// Calculate the common log
	log10 = Math.log(num) / Math.log(10.0);
	System.out.println("log base 10 = " + log10);
 
	// Calculate the antilogarithm of log base e
	aloge = Math.exp(loge);
	System.out.println("antilog of log base e = " + aloge);
 
	// Calculate the antilogarithm of log base 10
	alog10 = Math.pow(10.0, log10);
	System.out.println("anitlog of log base 10 = " + alog10);
    }
}

[edit] What Result You Can Get

Run the program, you will get:

log base e = -2.198225077669803
log base 10 = -0.9546770212133425
antilog of log base e = 0.111
anitlog of log base 10 = 0.11100000000000002

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

Need nothing.


[edit] How to Run this Java Example Program

We recommend running this Java example program with Eclipse.

For assistance in working with Eclipse, please see How to Run Java Program with Eclipse.

It's fairly easy.



[edit] Question & Answer

Any question?

Click edit and post your question or answer here.


Personal tools