The equations x = r cos (), y = rsin(),r 2 = x 2 + y 2 ,and tan() = y/x define t
ID: 3613006 • Letter: T
Question
The equations x = r cos (), y = rsin(),r2 = x2 + y2 ,and tan() = y/x define the relationship betweenCartesian coordinates (x,y) and polar coordinates (r,)
Assignment:
Write a program that prompts the user whether to convert fromCartesian coordinates to polar coordinates or the other way around;and then prompts the user for the name of an input file. Theinput file will contain a number of coordinates. The programwill read in and convert each coordinate in the inputfile. The converted coordinates are printed in an output filecalled “convert.out”. Use astructures to represent the points.
In order to do this assignment, you will need the mathematicsfunctions sin, cos, andtan. These functions are in the mathematicslibrary. You need to include this library in your program(i.e. the statement: #include <math.h> must beadded to your program). The sin,cos, and tan functions expects adouble value angle as anargument, and returns the double value as aresult. The value for angle must be inradians. For example, sin(/2) =1. Note /2 = 90°.
Suggested help for completing the assignment: Firstwrite a program that prompts the user to select the type ofconversion, prompts the user for each coordinate, and then displaysthe converted coordinate on the monitor screen. When you aresatisfied with the behavior of this program, modify the program toread in coordinates from an input file and put the result in theoutput file convert.out.