Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Tasks This project consists of 3 tasks: Task 1 Write a method that takes as inpu

ID: 3674709 • Letter: T

Question

Tasks

This project consists of 3 tasks:

Task 1

Write a method that takes as input parameters a pair of Cartesian coordinates and which sets as output parameters a pair of polar coordinates corresponding to the same point as the input Cartesian coordinates. Use degrees for output angles.

Task 2

Write a main program that:

prompts a user to input several pairs of positive Cartesian coordinates, one pair per line and separated by spaces. The user may enter up to 50 pairs, and the user will say he/she is done by inputting the coordinate pair (0, 0). Store the pairs in a pair of parallel arrays as you read them in.

shifts all coordinates to the right by 4 units and up by 7 units.

converts all shifted coordinate pairs to polar coordinates by calling the method you wrote.

prints lines showing both the input coordinates and output coordinates as ordered pairs in the style of this example: (4, 1) ---> (11.3137, 45)

Task 3

After successfully compiling and testing your program, change it to accept up to 100 coordinate pairs instead of up to 50. Also change the coordinate shift to be up 6 and to the right by 2.))))))

This is a sample interaction for the program before doing Task 3: Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop: 4 1 Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop: 1 4 Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop: 10 12 Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop: 1.1 4.5 Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop: 3 10.3 Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop: 10 7 Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop: 0 0 Coordinates [inputs ---> polar]:

================================

(4, 1) ---> (11.3137, 45)

(1, 4) ---> (12.083, 65.556)

(10, 12) ---> (23.6008, 53.6156)

(1.1, 4.5) ---> (12.5801, 66.0838)

(3, 10.3) ---> (18.6625, 67.9705)

(10, 7) ---> (19.799, 45)

Explanation / Answer

#include <iostream>
#include <math.h>
using namespace std;
void getrec(double& x, double& y);   
void polar(double x, double y, double& r, double& theta);
void showPolarCoord(double radius, double angle);
int main()
{
const int SIZE = 50;
double x[SIZE];
double y[SIZE];
double distance;
double angle;
getrec(x[SIZE],y[SIZE]);
polar(x, y, distance, angle);
}
int getrec (double x[], double y[])
{   
int count = 0;
do
{   
cout << "Enter the x coordinate: ";
cin >> x[count];
cout << "Enter the y coordinate: ";
cin >> y[count];
count++;
}
while (count <= SIZE && x[count-1] && y[count-1]);
return count;
}
void polar(double x, double y, double& r, double& theta)
{
const double toDegrees = 180.0/3.141593;
r = sqrt((pow(x,2))+(pow(y,2)));
theta = atan(y/x) * toDegrees;
return;
}
void showPolarCoord(double radius, double angle)
{
cout << "The polar coordinates are: " << endl;
cout << " Distance from origin: " << radius << endl;
cout << " Angle (in degrees) from x-axis: " << angle << endl;
return;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote