function program

I am taking my first programming class in c++ and I am struggling my way through it I am having some trouble with one of my programs it is suppose to be a function that converts latitude and longitude from degrees to radians then finds the distance between two points I enter in one coordinates and it gives me the correct radians but it skips everything else in the code and makes it 0 it will not allow me to enter the values

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//   
//      CPS 216
//      4/5/2014
// this program takes latitude and longitude in degreees
// and turns it into radians using a function


#include <iostream> // for input putput
#include <string> //
#include <cmath> // for calculation of conversrion

using namespace std;

// variables****************************************************************
const double pi= 3.1415;
double coord1(0),coord2(0),coord3(0),coord4(0);
double rad1,rad2,rad3,rad4;
double dist, direction,direction2,direction3,direction4;

// function to convert coordinates******************************************
double radiancoord(double coord,double direc)
{
    double n(1),N(1),E(1),e(1);
    double rad;
    if (direc=1)
    {
        rad = ((coord*pi)/180);
        return rad;
    }
    else
    {
        rad = -((coord*pi)/180);
        return rad;
    }

}
// distance function ************************************************************
double CoordDistance(double lat1,double lon1,double lat2, double lon2)
{
double distance;
distance = sqrt(pow((lat2-lat1),2)+pow((lon2-lon1),2))*3956.57;
return distance;
}

// begining of main code ****************************************************
int main()
{
// program definition********************************************************
    cout << "This program turns longitude and latitude in degrees" << endl;
    cout << " into radians and also tells the distance between 2 points" << endl;
    cout << "Positive is North/East negitive is South/West \n" << endl;

// get users first coordinate************************************************
    cout << "longitude/latitude" << endl;
    cout << "Enter the first locations coordinates: " ;

//enter longitude for first point
    cin  >> coord1;
    cin >> direction;

// enter latitude for first point
    cin >> coord2;
    cin >> direction2;

// put information into functions
    rad1=radiancoord(coord1,direction);
    rad2=radiancoord(coord2,direction2);

// output information from first point
    cout << "The location in radians is: " << rad1 <<", "<< rad2 << endl;
    cout << "\n";

// get users second coordinate************************************************
    cout << "longitude/latitude" << endl;
    cout << "Enter the second locations coordinates: " ;

// enter latitude
    cin  >> coord3;
    cin >> direction3;

// enter the longitude
    cin >> coord4;
    cin >> direction4;

// put information into function
    rad3=radiancoord(coord3,direction3);
    rad4=radiancoord(coord4,direction4);

// output coordinate
    cout << "The coordinates in radians are: " << rad3 <<", "<< rad4 << endl;
    cout << "\n";

// find the distance between points************************************
dist=CoordDistance(rad1,rad2,rad3,rad4);
cout << "the distance between the points is"<< endl;
cout << dist << " miles" << endl;

    return 0;
}


any advice would be a big help

Relational operator for equality check is "==" (double/two equal sign) not "=" (single equal sign).
 
@25 if (direc=1)
i tried that still the same problem where it only takes the first input and when i used == it made all of my coordinates negitive
What are the inputs fed to the program?
It works fine. Getting correct result/output for a couple of tests (place co-ordinates). Attaching them below:


This program turns longitude and latitude in degrees
into radians and also tells the distance between 2 points
Positive is North/East negitive is South/West

longitude/latitude
Enter the first locations coordinates: 12.9667
1
77.5667
1
The location in radians is: 0.226305, 1.35375

longitude/latitude
Enter the second locations coordinates: 9.9197
1
78.1194
1
The coordinates in radians are: 0.173126, 1.3634

the distance between the points is
213.838 miles



This program turns longitude and latitude in degrees
into radians and also tells the distance between 2 points
Positive is North/East negitive is South/West

longitude/latitude
Enter the first locations coordinates: 12.9667
1
77.5667
1
The location in radians is: 0.226305, 1.35375

longitude/latitude
Enter the second locations coordinates: 11.0183
1
76.9725
1
The coordinates in radians are: 0.1923, 1.34338

the distance between the points is
140.661 miles
Topic archived. No new replies allowed.