Question: Using SWI Prolog to do this question. Problem 4: Implement update, using Prolog's read, write, assert. % Update asks user for name and age,then %

Using SWI Prolog to do this question.

Problem 4: Implement update, using Prolog's read, write, assert.

% Update asks user for name and age,then

% asserts the answers in a structure: person(name(_), age(_)),

% then asks if the user wants to continue.

% (User must answer each question with a word

% or number ending in a period. No blanks

% allowed in answer. To simplify implementation

% of #4 and #5, user input must be all lowercase.)

% Test cases part I:

% ?- update.

% Name?: nancy.

% Age?: 22.

% Continue (y or n)?: y.

% Name?: steve.

% Age?: 100.

% Continue (y or n)?: x.

% Continue (y or n)?: n.

% true.

% Test cases part II:

% Ask Prolog to list all person structures

% to verify that update worked:

% ?- person(name(N), age(A)).

% N = nancy,

% A = 22;

% N= steve,

% A = 100;

% true.

% Type your Solution here:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!