0
1. Write the predicate spent(Passengers, Year, Sum)
 to find the total cost of tickets for passengers from
 of the list of Passengers in year Year.
trip(01, Kuiv, Odessa, 1500).
trip(02, Kuiv, Lviv, 700).
trip(03, Uzhorod, Krum, 6000).
trip(04, Vunohradiv, Odessa, 2540).
trip(05, Ternopil, Kuiv, 3800).
trip(06, Zaporizhya, Donetsk, 900).
trip(07, Lytsk, Mariupol, 7500).

ticket(01, Maha, 2021-12-26).
ticket(02, Burcho, 2021-05-21).
ticket(03, Chegil, 2021-06-18).
ticket(04, Dovhinka, 2022-12-05).
ticket(05, Voloshyn, 2022-07-14).
ticket(06, Kristian, 2022-03-17).
ticket(07, Bolehan, 2022-01-03).

trip(01, Kuiv, Odessa, 1500). trip(02, Kuiv, Lviv, 700). trip(03, Uzhorod, Krum, 6000). trip(04, Vunohradiv, Odessa, 2540). trip(05, Ternopil, Kuiv, 3800). trip(06, Zaporizhya, Donetsk, 900). trip(07, Lytsk, Mariupol, 7500).

ticket(01, Maha, 2021-12-26). ticket(02, Burcho, 2021-05-21). ticket(03, Chegil, 2021-06-18). ticket(04, Dovhinka, 2022-12-05). ticket(05, Voloshyn, 2022-07-14). ticket(06, Kristian, 2022-03-17). ticket(07, Bolehan, 2022-01-03).



sum_cash(Price) :- spent(sum(A), trip(_, _, _, A), Price).


I wrote this code, but it is not enough to complete the task, please help.
Mashka
  • 35
  • 4

0 Answers0