Can anyone help me with these Write PROLOG rules that will e

Can anyone help me with these??

Write PROLOG rules that will enable you to...

1.           Find year of birth of everyone who has first name Name (result may appear multiple times if multiple people have the same name/year). (1 mark)

question1(Name,Year) :- exists (person(Name,Surname,Date,_)).

2.           Find the first name of anyone who was born in Month (the name may appear multiple times if multiple people exist satisfying the rule). (1 mark) question2(Month,Name) :- ......

3.           Find the year of birth of children who have at least two (other) siblings and also find the first names of their parents (results may appear multiple times if multiple people have the same info). (1 mark) question3(Year,FatherName,MotherName) :- .......

4.           Find the first name and surname of mothers whose children’s combined incomes are less than £100,000, and where no child makes more than £30,000. The rule should also return the value of the children’s combined incomes. Same mother must not be

\"returned\" more than once. (2 marks)                  

question4(Name,Surname,CombinedIncome) :- ......

5.           Find the first names of parents (father and mother) whose family combined income

(that is, incomes of parents and all children put together) is greater than £120,000

(same family shall not be \"returned\" more than once). (2 marks) question5(FatherName,MotherName) :- ........

6.           Find each person’s first name and surname and give their income (you may make use of the supplied salary/2 predicate, which returns an income figure for everyone, whether or not they are in work). In addition, indicate each working person’s ‘earning status’ as one of employed, unemployed or retired as appropriate (very same person shall not be \"returned\" more than once). Implement any additional predicates that may be required to support your rule. (3 marks) question6(Name,Surname,Income,Status) :- ............

Solution

1.=> question1(Name,Year) :- exists (person(Name,Surname,Date,Firstname))

.2.           Find the first name of anyone who was born in Month (the name may appear multiple times if multiple people exist satisfying the rule). (1 mark)

=>question2(Month,Name) :- exists (person(FirstName,Surname,Date,Month))

3.Find the year of birth of children who have at least two (other) siblings and also find the first names of their parents (results may appear multiple times if multiple people have the same info). (1 mark)

=>question3(Year,FatherName,MotherName) :-exists ( person(number_siblings<=2,FirstName,LastName,Year))

4.

Find the first name and surname of mothers whose children’s combined incomes are less than £100,000, and where no child makes more than £30,000. The rule should also return the value of the children’s combined incomes. Same mother must not be \"returned\" more than once. (2 marks)                  

=>question4(Name,Surname,CombinedIncome) :- exists(person(income,total_income<30000,FirstName,LastName)

Can anyone help me with these?? Write PROLOG rules that will enable you to... 1. Find year of birth of everyone who has first name Name (result may appear multi

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site