Sunday, December 13, 2009

Expert System Application

Expert System which we made is about horoscope. Horoscope is a prediction of someone's future based on the relative positions of the planets (Source : Google).

Everyone absolutely have horoscope. So, We want to help everyone to know his/her horoscope by entering date and month of their birthday.

The logic to make the program which can show a horoscope, the program must have a function to receive input date and month of their birthday. Then the program will check the program like this :

- Date of born 22 December -19 January, the program conclude the horoscope is Capricorn.
- Date of born 20 January -18 February, the program conclude the horoscope is Aquarius.
- Date of born 19 February -20 March, the program conclude the horoscope is Pisces.
- Date of born 21 March -19 April, the program conclude the horoscope is Aries.
- Date of born 20 April - 20 May, the program conclude the horoscope is Taurus.
- Date of born 21 May - 21 June, the program conclude the horoscope is Gemini.
- Date of born 22 June - 22 July, the program conclude the horoscope is Cancer.
- Date of born 23 July - 22 August, the program conclude the horoscope is Leo.
- Date of born 23 August -22 September, the program conclude the horoscope is Virgo.
- Date of born 23 September-23 October, the program conclude the horoscope is Libra.
- Date of born 24 October – 21 November, the program conclude the horoscope is Scorpio.
- Date of born 22 November- 21 December, the program conclude the horoscope is Sagittarius.

So, We can write the source code like this :

get_answer(Ans1,Ans2):-repeat,write('Enter the date (ended by writing dot mark) : '),read(Ans1),write('Enter your birth month (ended by writing dot mark) : '),read(Ans2),member(Ans1,[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]),member(Ans2,[january,february,march,april,may,june,july,august,september,october,november,december]),nl,nl,write('Your birthday is '),write(Ans1),write(' '),write(Ans2),nl,(Ans2==january,Ans1<20,write('So, Your Horoscope is : Capricorn'),nl;Ans2==february,Ans1>28,write('It is Imposible, because February just have 28 days !!'),nl;Ans2==december,Ans1>21,write('So, Your Horoscope is : Carpicorn'),nl;Ans2==january,Ans1>19,write('So, Your Horoscope is : Aquarius'),nl;Ans2==february,Ans1<19,write('So, Your Horoscope is : Aquarius'),nl;Ans2==february,Ans1>18,Ans1<29,write('So, Your Horoscope is : Pisces'),nl;Ans2==march,Ans1<21,write('So, Your Horoscope is : Pisces'),nl;Ans2==march,Ans1>20,write('So, Your Horoscope is : Aries'),nl;Ans2==april,Ans1<20,write('So, Your Horoscope is : Aries'),nl;Ans2==april,Ans1>19,Ans1<31,write('So, Your Horoscope is : Taurus'),nl;Ans2==april,Ans1==31,write('It is Imposible, because April just have 30 days !!'),nl;Ans2==may,Ans1<21,write('So, Your Horoscope is : Taurus'),nl;Ans2==may,Ans1>20,write('So, Your Horoscope is : Gemini'),nl;Ans2==june,Ans1<22,write('So, Your Horoscope is : Gemini'),nl;Ans2==june,Ans1>21,Ans1<31,write('So, Your Horoscope is : Cancer'),nl;Ans2==june,Ans1==31,write('It is Imposible, because June just have 30 days !!'),nl;Ans2==july,Ans1<23,write('So, Your Horoscope is : Cancer'),nl;Ans2==july,Ans1>22,write('So, Your Horoscope is : Leo'),nl;Ans2==august,Ans1<23,write('So, Your Horoscope is : Leo'),nl;Ans2==august,Ans1>22,write('So, Your Horoscope is : Virgo'),nl;Ans2==september,Ans1<23,write('So, Your Horoscope is : Virgo'),nl;Ans2==september,Ans1>22,Ans1<30,write('So, Your Horoscope is : Libra'),nl;Ans2==september,Ans1==31,write('It is Imposible, because September just have 30 days !!'),nl;Ans2==october,Ans1<24,write('So, Your Horoscope is : Libra'),nl;Ans2==october,Ans1>23,write('So, Your Horoscope is : Scorpio'),nl;Ans2==november,Ans1<23,write('So, Your Horoscope is : Scorpio'),nl;Ans2==november,Ans1>21,Ans1<31,write('So, Your Horoscope is : Sagittarius'),nl;Ans2==november,Ans1==31,write('It is Imposible, because November just have 30 days !!'),nl;Ans2==december,Ans1<22,write('So, Your Horoscope is : Sagittarius'),nl),!.

















(Click the image if can't see well)

The source code means that everytime user want to use this program, user must entering command "get_answer(Variable1,variabel2)". Variabel1 and variabel2 can change with another variabel name. This program use ARRAY to declare the value of the date and the month of user birthday. For the date, the value of array is from 1 to 31. For the month, the value is from january to december. But february just have 28 day, So we make a condition, if user input 29 for the date of february, the program will show a notification. Like february, if user input 31 for the date of april, june, september, and november, the program also show the notification.

For start the program, entering command get_answer(Variabel1,Variabel2). For example : We use Variabel "Date" and "Month.

Note : variabel must writing a upper case in every first character of name. For example : "Date". Not allowed if you write "date".
















(Click the image if can't see well)

Enter the date of your born (just date, without month and ended by writing dot "." mark). For example : type "7"
















(Click the image if can't see well)

Then, Enter the month of your born (enter the name month in English. For example : april or june. Don't forget to write the dot "." mark in the end of the month). For example : type "april"
















(Click the image if can't see well)

The Result :
















(Click the image if can't see well)

0 comments:

Post a Comment

About This Blog

This Blog created to complete Discrete Math Assignment. This Blog contain all about discrete math subject especially Prolog programming. The member of team are Fahri Reza, Izzat, Chandra and Catur. We are from Discrete Math class A at Information System Department faculty of Information Technology INSTITUT TEKNOLOGI SEPULUH NOPEMBER (ITS) Surabaya. We hope all existing posts on this blog will be useful for all people. And thanks for visiting our Blog..

Followers

  © Blogger template PingooIgloo by Ourblogtemplates.com 2009 | The Permutation Team's Blog 2009

Back to TOP