I'm new to Prolog, and so I came here to know and learn about this new language from you fine people.
I'm writing a function 'decision' which has 3 parameters I=income, D= dependents, S=savings, and im trying to find out if the person should invest in savings, stocks, or both.
Here, is my code...
decision(I, D, S) :-
Minincome is 9000 + 2500*D,
Minsaving is D*3000,
saving(S, Minsaving) :- S < Minsaving, write('You should invest your money into savings. ').
saving(S, Minsaving) :- S >= Minsaving,
income(I, Minincome) :- I > Minincome, write('You should try to invest in NYSE stock market. ');
income(I, Minincome) :- I =< Minsaving, write('You should invest your money into both, saving and stock market. ').
What I'm trying to do is if person has saving less than Minsaving, than he should invest in savings,
else if a person has savings greater than Minsaving and income greater than Minincome, than he should invest in stock market,
else if a person has savings greater than Minsaving and income less than Minincome, than he should invest in stock market as well as savings.
I hope i was clear. Thanks
Aucun commentaire:
Enregistrer un commentaire