-
Coordinate Input
I need to know how to obtain co-ordinate input for a program that uses Heron's theorem (Area=sqrt(s(s-a)(s-b)(s-c)) where s=1/2 perimeter and a,b,c are the lengths of the sides. I'm at a loss for where and how to store these co-ordinates once the user inputs them. If someone could give me a clue I'd be much obliged.
-
Is there a reason you can't just have the user enter them using cin? Maybe you could read them in from a file as needed?
-
No, I know it needs cin, but I need to know what data type to store it in or something. I'm confused about how a pair of coordinates should be stored.
-
Maybe if the x and y co-ordinates are stored separately? But there has to be a way to obtain and store two numbers at once, doesn't there?
-
-
This will probably make more sense in context of the whole assignment:
An engineer needs to know the perimeter and area of triangular plots of land. He can input the coordinates (+/-100, +/-100) of each vertex. Using the distance formula allows you to calculate the lenght of each side and consequently the perimeter. Using Heron's Theorem (Area =sqrt(s(s-a)(s-b)(s-c)) where s =1/2 perimeter and a,b,c, are the lengths of the triangle's sides) you can calculate the area. Your assignment is to write an application that allows the engineer to calculate multiple triangle measures. Your application needs to obtain coordinates, error trap for invalid coordinates (those greater than positive 100 or less than negative 100), calculate the length of a side, calculate the lenght of the perimeter, determine if three points create a triangle (sum of length of any 2 sides must be greater than the length of the third side). This is at least five functions. You need to output your results to standard output showing the coordinates of the points input, the length of each side, the perimeter, ther area, and the ratio of the area to the perimeter.
So now I'm thinking I'm going to have to obtain each x and y coordinate separately. Is there another way?
-
I think Mr. Johnson would flip out if I used structures we haven't learned in class. I'll try though...
-
If you think it might cause a problem to use structures then why not just make seperate ints to hold the values?