Simple problem with n points on a plane

Hello all!
I am very new to programming in C++ and I have to solve a question that asks the user to give the coordinates of n points in a plane and then outputs which quadrant has the most amount of points as an answer. I know how to check if a given point is in one of the quadrants or the axis, I'll use else if statements for the x,y coordinates but how do I count how many of them were in the quadrant and display the quadrant with the maximum amount of points?

Also, most of the beginner programs I have encountered have to have some sort of a control system, e.g. if your program looks at only positive numbers, when you enter a negative number the program will prompt you to enter a positive one instead. I don't know what would be te control for such a problem, because any real number should be fine. Do I only have to account for letter as problematic inputs or is there something else I should consider?

Thank you in advance for your help!
Last edited on
Use counters. Something like
1
2
3
4
5
6
7
8
9
10
11
12
if(the condition you know){
first++;
}
else if(second condition you know){
second++;
}
else if(...){
third++;
}
else if(...){
fourth++;
}


You can check for invalid input also. See for example
http://www.cplusplus.com/reference/clibrary/cctype/isalpha/

For floating point numbers check is more complex but for just checking if letter is entered is easier.
Topic archived. No new replies allowed.