1: /*
2: Names: igor Moura and Toby Tirona
3: Version 1.0
4: The user inputs x and y coordinates. The code outputs the point's radius and
5: angle in both radians and degrees.
6:
7:
8: */
9:
10: #include <iostream>
11: #include<cstdlib>
12: #include <cmath>
13: using namespace std;
14:
15: int main () {
16:
17: double x = 0;
18: double y = 0;
19: double radius = 0;
20: double angle = 0;
21:
22: cout << " Write X: "<< endl;
23: cin >> x ;
24: cout << " Write Y: "<< endl;
25: cin >> y ;
26:
27:
28:
29: angle = atan(y/x);
30: cout << "angle in radians: " << angle << endl;
31:
32: cout << "angle in degree: " << angle*180/M_PI << endl;
33:
34:
35:
36:
37: x = pow( x , 2 );
38: y = pow(y, 2);
39: radius = sqrt(x + y);
40:
41: cout << "Radius = " << radius << endl;
42:
43: return EXIT_SUCCESS;
44: }
45: /*
46: test 1 :
47: Write X:
48: -0.5
49: Write Y:
50: -0.866
51: angle in radians: 1.04718
52: angle in degree: 59.9993
53: Radius = 0.999978
54:
55: test 2 :
56: Write X:
57: 1
58: Write Y:
59: 1
60: angle in radians: 0.785398
61: angle in degree: 45
62: Radius = 1.41421
63:
64: test 3:
65: Write X:
66: -2
67: Write Y:
68: 2
69: angle in radians: -0.785398
70: angle in degree: -45
71: Radius = 2.82843
72:
73: test 4:
74: Write X:
75: 0.3
76: Write Y:
77: -0.6
78: angle in radians: -1.10715
79: angle in degree: -63.4349
80: Radius = 0.67082
81:
82: test 5:
83: Write X:
84: 15
85: Write Y:
86: -4.7
87: angle in radians: -0.303644
88: angle in degree: -17.3975
89: Radius = 15.7191
90:
91:
92:
93:
94:
95: */
96:
97: