×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Prolog quiz

## Prolog quiz

(OP)
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).

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!