# Prolog quiz

Status
Not open for further replies.

#### 0741044035

##### Technical User
I created a small program for finding out which is the risk to have cardiovascular diseases.
The problem is when I type something different than y(yes).. it doesn't always stop and keeps asking me the same questions. How can I make it stop and accept all kinds of answers?
Thanks a lot!

predicates
risk(symbol)
age(symbol)
smoke(symbol)
diabet(symbol)
obesity(symbol)
rel(symbol,symbol)
infl_age(integer)
infl_smoke(integer)
infl_diabet(integer)
infl_obesity(integer)

clauses

risk(extreme) if infl_age(A),infl_smoke(B),infl_diabet(C),infl_obesity(D), A+B+C+D>90.
risk(big) if infl_age(A),infl_smoke(B),infl_diabet(C),infl_obesity(D), A+B+C+D>70.
risk(medium) if infl_age(A),infl_smoke(B),infl_diabet(C),infl_obesity(D), A+B+C+D>40.
risk(low) if infl_age(A),infl_smoke(B),infl_diabet(C),infl_obesity(D), A+B+C+D>20.
risk(safe) if !.

age(X) if rel(age,X).
smoke(X) if rel(smoke,X).
diabet(X) if rel(diabet,X).
obesity(X) if rel(obesity,X).

infl_age(20) if age(over_50),!.
infl_age(10) if age(between_30_and_50),!.
infl_age(0) if !.

infl_smoke(30) if smoke(do_you_smoke),!.
infl_smoke(0) if !.

infl_diabet(25) if diabet(are_you_diabetic),!.
infl_diabet(0)if !.

infl_obesity(25) if obesity(are_you_a_fat_person),!.
infl_obesity(0) if !.

goal

risk(X),
write("the risk for having cardiovascular ilnesses is:",X).

Status
Not open for further replies.

Replies
0
Views
33
Replies
0
Views
82
Replies
0
Views
93
Replies
0
Views
85
Replies
6
Views
106