(The cities.txt file is just a list of almost 30,000 cities and their distance from Charlotte)
code;
//Include libraries
#include<iostream>
#include<fstream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<iomanip>
//Use namespace
using namespace std;
//Declare variable
double lClng =-80.8290;
//Declare variable
double lCltt = 35.2060;
//Declare variable
double lR = 3959;
//Declare variable
const double lPi = 3.14159265358979323846;
//Define class
class Distance
{
//Declare access specifier
private:
//Declare variable
double lTti;
//Declare variable
double lLngi;
//Declare access specifier
public:
//Declare variable
string city;
//Declare variable
string state;
//Declare variable
double D;
//Call method
Distance();
//Define method
Distance(string la, string lb, string lc, string d);
//Define method
void Calculate();
};
//Define method
Distance :: Distance()
{
//Assign value
lTti = 0.0;
//Assign value
lLngi = 0.0;
//Assign value
city = "Unknown";
//Assign value
state = "Unknown";
}
//Define method
Distance :: Distance(string la, string lb, string lc, string d)
{
//Assign value
city = la;
//Assign value
state = lb;
//Assign value
lTti = atof(lc.c_str());
//Assign value
lLngi = atof(d.c_str());
}
//Define method
void Distance :: Calculate()
{
//Assign value
double lDln = lLngi - lClng;
//Assign value
double lDlt = lTti - lCltt;
//Assign value
lDlt = lDlt * (lPi/180);
//Assign value
lDln = lDln * (lPi/180);
//Assign value
lCltt = lCltt * (lPi/180);
//Assign value
lTti = lTti * (lPi/180);
//Assign value
double la = pow(sin(lDlt/2),2) + cos(lCltt)*cos(lTti)*pow(sin(lDln/2),2);
//Assign value
double lc = 2 * atan2(sqrt(la), sqrt(1-la));
//Compute value
D = lR*lc;
}
//Define main
int main()
{
//Open file
ifstream theFile("cities.txt");
//Open file
ofstream test("dist_clt.txt");
//Declare variable
string line;
//Declare variable
string s;
//Declare variable
string lc;
//Declare variable
string lon;
//Declare variable
string lat;
//Loop
while(theFile)
{
//Get value
getline(theFile,lc,',');
//Get value
getline(theFile,s,',');
//Get value
getline(theFile,lat,',');
//Get value
getline(theFile,lon);
//Create instance
Distance test1(lc,s,lat,lon);
//Call method
test1.Calculate();
//Write
test << lc << "," << s << "," << test1.D<<endl;
}
//Pause console window
system("pause");
//Return
return 0;
}
(The cities.txt file is just a list of almost 30,000 cities and their distance from Charlotte)...
C++ Programming Hi! Sorry for all the material attached. I simply need help in writing the Facility.cpp file and the other files are included in case they're needed for understanding. I was able to complete the mayday.cpp file but am stuck on Facility. The following link contains a tar file with the files provided by the professor. Thank you so much in advanced! http://web.cs.ucdavis.edu/~fgygi/ecs40/homework/hw4/ Closer.h: #ifndef CLOSER_H #define CLOSER_H #include <string> #include "gcdistance.h" struct Closer { const double latitude, longitude;...