This is a discussion on ? within the C++ Programming forums, part of the General Programming Boards category; Dear C++ Programmers, I need your help. i would like to ask how I could get my program to read ...

  1. #1
    Registered User
    Join Date
    Jan 2002


    Dear C++ Programmers,

    I need your help.
    i would like to ask how I could get my program to read coordinates i.e (21.5 W) this is a longitude!


  2. #2
    Registered User
    Join Date
    Dec 2001
    I'm not an expert, but I'm sure the experts will want to know how your program will get the coordinates (cout, ifstream, etc) and what they will be used for so they can put in a proper type for the rest of the program

  3. #3
    Registered User
    Join Date
    Jan 2002
    Dear C++ Programers,

    I want to know if there is a code I could write in C++ or import from Java or C and incorporate in my C++ program to accept input in the form of Coordinates namely; longitude and latitude e.g 21.5W {note all values in degrees} and use them in a calculation involving the Azimuthal angle of a satellite earth station.

    Thanks alot,

  4. #4
    Registered User heat511's Avatar
    Join Date
    Dec 2001

    Azimuthal angle of a satellite earth station!?

    are you trying to launch nuclear weapons?


    are you looking for something like this?

    int intcoordinate;
    char chardirection[1];
    int toupper(int c);
    cout << "Enter the coordinates" << endl;
    cin >> intcoordinate;
    cout << "Enter the direction(E, W, S, N)" << endl;
    cin >> chardirection[0];
    chardirection[0] = toupper(int(chardirection[0]))
    if(int(chardirection[0]) == 87)
    //code goes here for West direction
    //then all you need to do make 3 more if then statements
    //one for each direction and enter your math equation thing
    hope that helps

  5. #5
    21.5 W is either a string, if it is all one variable, or a combination of a double and a character. If you view it as the latter, then having the coordinates be a class or a struct has some merit. Here's a skeletal version of a possible class:

    class Longitude
    double value;
    char direction;

    //using default methods
    void setValue(double);
    void setDirection(char );
    double getValue() const;
    char getDirection() const;
    void display() const;

    //example of function definition:
    void Longitude::display()
    cout << value << ' ' << direction;

    int main()
    //declare instance of Longitude using default default constructor
    Longitude coord1;

    //supply instance of Longitude with hard coded data, not very flexible

    //do something with the object

    //and away you go.

    It is easier to code, but produces a less stable environment, if you use all public members. Using private data members with public accessor and mutator functions is the prefered approach in the long run.

Popular pages Recent additions subscribe to a feed

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