add(X, Y, Sum) :- Sum is X + Y.

around(Prev,X,Next) :- Prev is X - 1, Next is X + 1.

area(rectangle(W,H), A) :- A is W * H.

area(circle(R), A) :- A is pi * R ** 2.

length(point(X1,Y1),point(X2,Y2),Length) :- Length is sqrt((X1-X2)**2+(Y1-Y2)**2).

grade(Score,Grade) :- Score >= 90, Grade = 'A'.
grade(Score,Grade) :- Score >= 80, Score < 90, Grade = 'B'.
grade(Score,Grade) :- Score >= 70, Score < 80, Grade = 'C'.
grade(Score,Grade) :- Score < 70, Grade = 'F'.

print_grade(Score) :- grade(Score,Grade),
    format('~w -> ~w\n', [Score, Grade]).
