Starting from:
$35

$29

Program 4 • Logic Programming : Prolog" Solution

1. Logic Programming in Prolog




You will use Prolog to write an airline reservation system for the Twilight Zone Air-lines. Given a request to travel from one city to another, print out the flight schedule. For each leg of the trip, print out the departure airport, airport, city name, and time. For example :




| ?- fly( lax, sea).




depart LAX Los Angeles 14:22




arrive SFO San Francisco 15:29




depart SFO San Francisco 16:02




arrive SEA Seattle-Tacoma 17:42




true ?




yes




A database has been provided which lists some airports, their cities, and the North latitudes and West longitudes of the airports. A flight schedule has also been pro-vided listing the departure and arrival airports and the departure times.




2. Logic




Some notes about the logic of the program.




To compute the distance between airports, use the HAVERSINE FORMULA. Note that the database contains degrees and minutes, which must be converted to radians. The result must be converted to miles.



All flight times are in Twilight Zone Standard Time (TZST), so you don’t need to handle PST, PDT, etc.



Planes fly at a constant speed of 500 miles per hour and always using great circle paths, so the arrival time can be computed from the departure time.



A flight transfer always takes 30 minutes, so during a transfer at a hub, the departure of a connecting flight must be at least 30 minutes later than the arrival of the incoming flight.



There are no overnight trips. The complete trip must depart and arrive in the same day.



See the notes on using the Haversine formula for computing great circle dis-tances.



What to Submit



Submit one file : functions.pl. Also submit README, and if applicable, PARTNER. The grader will copy in the files .score/database.pl and the test data.

More products