Noob Help with project

I'm pretty new to c++ and need help getting started with a programming project. For this project I have to take input parameters as Cartesian coordinates and set output parameters corresponding to the input Cartesian coordinates.

- It has to prompt a user to input coordinates, a pair a line separated by spaces. The max user amount to be entered has to be 25 and the user has to to enter (0,0) to end the program. The pairs have to be stored in parallel arrays.

- shift the coordinates to the right by 5 and up by 10

- convert all the coordinates to polar by calling the method

- It has to look like this:
1
2
3
4
5
6
7
  Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop: 44 3
Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop: 3 11
Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop: 5 6
Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop: 0 0

(10, 12) --> (21.428, 37.3)


Please help because I'm quite lost.

Edit: There needs to be a method that takes input parameters as a pair of Cart coordinates and sets as output parameters a pair of polar coord.
Last edited on
I think I can help with some of this, my maths isn't up to scratch for converting cartesian coordiantes to a polar whatever that means.

As for the programming, the following should get you started with some code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// I think this is what it means by parallel arrays
std::vector<int> x_coord;
std::vector<int> y_coords;

std::cout << "Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop: ";
int x, y;
std::cin >> x >> y;
// Do some checking, if 0 0 was entered, exit, else carry on
// Right by 5 is adding 5 to x
x = x+5;
// Up 10 is adding 10 to y
y = y + 10;
// The push backs below match each element in both arrays to it's corresponding coordinate, i.e x_coords[0] and y_coords[0] are a pair 
x_coords.push_back(x);
y_coords.push_back(y);


EDIT - Reworded some things and added transformation code
Last edited on
There are a couple of related problems posted by others:
http://www.cplusplus.com/forum/beginner/186229/
http://www.cplusplus.com/forum/general/186062/

You may get some ideas there.

But beware - there may be lots of errors in those posts too, so don't just copy without giving things some thought of your own.
Topic archived. No new replies allowed.