Below is the syntax highlighted version of Polar.java
from §1.2 Built-in Types of Data.
/************************************************************************* * Compilation: javac Polar.java * Execution: java Polar x y * * Read in Cartesian coordinates (x, y) and print out polar coordinates * (r, theta). * *************************************************************************/ public class Polar { public static void main(String[] args) { double x = Double.parseDouble(args[0]); double y = Double.parseDouble(args[1]); double r = Math.sqrt(x*x + y*y); double theta = Math.atan2(y, x); System.out.println("r = " + r); System.out.println("theta = " + theta); } }