Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement the cpp program faclity.cpp that uses the provided class facility.h and can be tested with the provided program testFacility.cpp Instrutions of facility.cpp are provided

Implement the cpp program faclity.cpp that uses the provided class facility.h and can be tested with the provided program testFacility.cpp

Instrutions of facility.cpp are provided below--

Facility(string s)

The constructor takes a singlestringargument. The argumentscontains a full line read from theFacilities.txtfile. The constructor should initialize the data members ofFacilityby selecting the appropriate substrings from the argument. The latitude and longitude fields should be converted to double values using theconvert_latitudeandconvert_longitudemember functions. The sign of thelatitude_andlongitude_data members should be determined by checking whether the latitude and longitude fields end withNorS,andEorWrespectively.

string site_number(void) const

This function returns the facility's site number.

string type(void) const

This function returns the facility's type.

string code(void) const

This function returns the facility's code.

string name(void) const

This function returns the facility's name.

double latitude(void) const

This function returns the latitude of the facility in degrees decimal. Latitudes in the southern hemisphere are negative numbers.

double longitude(void) const

This function returns the longitude of the facility in degrees decimal. Longitudes in the western hemisphere are negative numbers.

double distance(double lat, double lon) const

This function returns the distance in nautical miles between the facility and the position defined by (lat,lon) in degrees decimal. The implementation of this function uses thegcdistancefunction provided in filesgcdistance.handgcdistance.cpp.

double convert_latitude(string s) const

This function converts the stringsrepresenting a latitude in seconds decimal to adoublevalue in degrees decimal. One degree is 3600 seconds. The sign of the result is positive if the stringsends withNand negative if it ends withS. For example, the latitude represented by the string135427.7000Nshould be converted to the value37.6188

double convert_longitude(string s) const

This function converts the stringsrepresenting a longitude in seconds decimal to adouble

value in degrees decimal. One degree is 3600 seconds. The sign of the result is positive if the stringsends withEand negative if it ends withW. For example, the longitude represented by the string440551.5000Wshould be converted to the value-122.3754.

//

// Facility.h

//

#ifndef FACILITY_H

#define FACILITY_H

#include

class Facility

{

public:

Facility(std::string s);

std::string site_number(void) const;

std::string type(void) const;

std::string code(void) const;

std::string name(void) const;

double latitude(void) const;

double longitude(void) const;

double distance(double lat, double lon) const;

private:

const std::string site_number_;

const std::string type_;

const std::string code_;

const std::string name_;

const double latitude_, longitude_;

double convert_latitude(std::string s) const;

double convert_longitude(std::string s) const;

};

#endif

//

// testFacility.cpp

//

#include \"Facility.h\"

#include

#include

using namespace std;

int main()

{

string line;

getline(cin,line);

Facility f(line);

cout

cout

cout

}

example of input--

02187.*A AIRPORT SFO 01/05/2017AWPSFO CACALIFORNIA SAN MATEO CASAN FRANCISCO SAN FRANCISCO INTL PUPUCITY & COUNTY OF SAN FRANCISCO PO BOX 8097 SAN FRANCISCO, CA 94128 650-821-5000JOHN L. MARTIN PO BOX 8097 SAN FRANCISCO, CA 94128 650-821-500037-37-07.7000N 135427.7000N122-22-31.5000W440551.5000WE 13.1S14E2015 SAN FRANCISCO 08SE 5207ZOA ZCOOAKLAND NOAK OAKLAND 1-800-WX-BRIEF SFO Y04/1940O I E S 05/1973 NGPRY NO OBJECTION NYNYF F04292016 100LLA MAJORMAJORHIGH/LOW SS-SR Y122.950 N CG Y 001000009001 004 354151 05955600794701368600242212/12/20153RD PARTY SURVEY10/22/20143RD PARTY SURVEY10/22/2014 HGR,TIE AFRT,AVNCS,CARGO,CHTR,INSTR Y-LKSFO

example of output--

02187.*A AIRPORT SFO SAN FRANCISCO INTL 37.6188 -122.3754 1053.7350

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

Students also viewed these Programming questions

Question

Write a structured flowchart for prob.2.3

Answered: 1 week ago

Question

Create a dotplot for the following data set. 2 1 3 1 0 2 1 0 2 2

Answered: 1 week ago

Question

What is meant by the phrase Communication has a consequence?

Answered: 1 week ago