rendered paste body//John Harrison, Assignment 8
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
const double PI = acos(-1);
void polar(double x, double y, double& r, double& rt)
{
if (x == 0 && y == 0)
{
r = 0;
rt = 0;
}
else
{
r = sqrt(pow(x,2) + pow(y,2));
rt = atan(y/x);
}
}
int main()
{
double x, y, r, rt;
cout << "Enter a x coordinate: " << endl;
cin >> x;
cout << "Enter a y coordinate: " << endl;
cin >> y;
polar(x,y,r,rt);
double dt = rt*180/PI;
cout << fixed << setprecision(2) << "Polar coordinates for x and y values entered: R = " << r
<< ". Theta = " << rt << " radians or \n" << dt << " degrees." << endl;
cin.get();
cin.get();
}