Thread: Coordinate Input

  1. #1
    High school loser
    Join Date
    Dec 2004
    Posts
    27

    Question 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.
    Last edited by applescruff; 01-24-2005 at 07:15 PM.

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    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?

  3. #3
    High school loser
    Join Date
    Dec 2004
    Posts
    27
    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.

  4. #4
    High school loser
    Join Date
    Dec 2004
    Posts
    27
    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?

  5. #5

  6. #6
    High school loser
    Join Date
    Dec 2004
    Posts
    27
    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?

  7. #7
    High school loser
    Join Date
    Dec 2004
    Posts
    27
    I think Mr. Johnson would flip out if I used structures we haven't learned in class. I'll try though...

  8. #8
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    If you think it might cause a problem to use structures then why not just make seperate ints to hold the values?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Input statement problem
    By une in forum C Programming
    Replies: 3
    Last Post: 05-29-2007, 11:16 PM
  2. For loop problems, input please.
    By xIcyx in forum C Programming
    Replies: 2
    Last Post: 04-22-2007, 03:54 AM
  3. I would love some input on my BST tree.
    By StevenGarcia in forum C++ Programming
    Replies: 4
    Last Post: 01-15-2007, 01:22 AM
  4. Stupid Question
    By digdug4life in forum C++ Programming
    Replies: 22
    Last Post: 05-17-2005, 11:43 AM
  5. Help with Input Checking
    By Derek in forum C Programming
    Replies: 7
    Last Post: 06-17-2003, 03:07 AM