Coordinate Input

This is a discussion on Coordinate Input within the C++ Programming forums, part of the General Programming Boards category; 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 ...

  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
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    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
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735

  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-30-2007, 12:16 AM
  2. For loop problems, input please.
    By xIcyx in forum C Programming
    Replies: 2
    Last Post: 04-22-2007, 04: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, 12:43 PM
  5. Help with Input Checking
    By Derek in forum C Programming
    Replies: 7
    Last Post: 06-17-2003, 04:07 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21