Program to convert polar co | Java code of above approach ; Function to convert degree to radian ; Function to convert the polar coordinate to cartesian ; Convert degerees to radian ; Applying the formula : x = rcos ( theata ) , y = rsin ( theta ) ; Print cartesian coordinates ; Driver code ; Given polar coordinates ; Function to convert polar coordinates to equivalent cartesian coordinates
import java . util . * ; class GFG { static double ConvertDegToRad ( double degree ) { double pi = 3.14159 ; return ( degree * ( pi / 180.0 ) ) ; } static void ConvertToCartesian ( double [ ] polar ) { polar [ 1 ] = ConvertDegToRad ( polar [ 1 ] ) ; double [ ] cartesian = { polar [ 0 ] * Math . cos ( polar [ 1 ] ) , polar [ 0 ] * Math . sin ( polar [ 1 ] ) } ; System . out . print ( String . format ( " % .3f " , cartesian [ 0 ] ) + " ▁ " + String . format ( " % .3f " , cartesian [ 1 ] ) ) ; } public static void main ( String [ ] args ) { double [ ] polar = { 1.4142 , 45 } ; ConvertToCartesian ( polar ) ; } }