/* Filename: major.pro Programmer: Br. David Carlson Date of creation: June 22, 1988 Revised: December 9, 1999 to run under yap. Description: This program will advise as to what major(s) are best for a student based on grades and interest. Start the program with the goal: advise. Caveat: This is just a rough demo program, do not take its advice too seriously. */ :- dynamic graderecord/2, likesrecord/2, otherrecord/2. advise :- major(Subject), write('Suggested major: '), write(Subject), nl, fail. advise :- write('*** end of list ***'), nl, clear_dbase. clear_dbase :- clear_grades, clear_likes, clear_advwork. clear_grades :- retract(graderecord(_, _)), clear_grades. clear_grades. clear_likes :- retract(likesrecord(_, _)), clear_likes. clear_likes. clear_advwork :- retract(otherrecord(_, _)), clear_advwork. clear_advwork. major('CIS') :- likes('science'), potential('science'), potential('Foreign Language'), potential('math'), potential('logical reasoning'), potential('abstract thinking'). major('math') :- likes('math'), potential('science'), potential('math'), potential('logical reasoning'), potential('abstract thinking'). major('English') :- likes('literature'), likes('writing'), potential('writing'). major('Foreign Language') :- likes('Foreign Language'), potential('Foreign Language'), potential('verbal skills'). major('business') :- likes('business'). major('physics') :- likes('science'), potential('science'), potential('math'). major('communication') :- potential('writing'), potential('verbal skills'). major('economics') :- likes('economics'), likes('business'), potential('math'). major('education') :- likes('teaching'), likes('young people'), potential('verbal skills'). major('engineering') :- likes('science'), potential('science'), potential('math'). major('history') :- likes('history'), potential('writing'). major('chemistry') :- likes('science'), potential('science'), potential('math'). major('biology') :- likes('science'), potential('science'), potential('math'). major('liberal arts') :- likes('liberal arts'), potential('writing'). major('psychology') :- likes('psychology'). major('music') :- likes('music'), potential('music'). major('art') :- likes('art'), potential('art'). major('home economics') :- likes('home economics'). major('medical technology') :- likes('medicine'), likes('science'), potential('science'), potential('math'). major('philosophy') :- likes('philosophy'), potential('logical reasoning'), potential('abstract thinking'), potential('writing'). major('political science') :- likes('political science'), likes('history'). major('religious studies') :- likes('religious studies'), likes('history'), potential('writing'). major('social work') :- likes('social work'), likes('family studies'), likes('people'). potential(Subject) :- grade(Subject, good), !. potential(Subject) :- grade(Subject, ok), otherReason(Subject). grade(Subject, Grade) :- graderecord(Subject, Grade), !. grade(Subject, _) :- graderecord(Subject, _), !, fail. grade(Subject, Grade) :- askgrade(Subject), graderecord(Subject, Grade). likes(Subject) :- likesrecord(Subject, yes), !. likes(Subject) :- likesrecord(Subject, no), !, fail. likes(Subject) :- asklikes(Subject). otherReason(Subject) :- otherrecord(Subject, yes), !. otherReason(Subject) :- otherrecord(Subject, no), !, fail. otherReason(Subject) :- askother(Subject). askgrade(Subject) :- write('Ability in '), write(Subject), write(' is (good, ok, poor): '), read(Grade), asserta(graderecord(Subject, Grade)). asklikes(Subject) :- write('Student likes '), write(Subject), write(' (y/n): '), read(Reply), positive(Reply), !, asserta(likesrecord(Subject, yes)). asklikes(Subject) :- asserta(likesrecord(Subject, no)), !, fail. askother(Subject) :- write('For other reasons the student has potential in '), write(Subject), write(' (y/n): '), read(Reply), positive(Reply), !, asserta(otherrecord(Subject, yes)). askother(Subject) :- asserta(otherrecord(Subject, no)), !, fail. positive(y). positive(yes). positive('Y'). positive('Yes'). positive('YES').