Menu Rumus Matematik Prolog
menu :-
write('=====MENU====='),nl,
write('1. Luas Segitiga'),nl,
write('2. Volume Balok'),nl,
write('3. Volume Kubus'),nl,
write('4. EXIT'),nl,
write('Masukkan pilihan : '), read(PIL), nl,
(PIL=1,nl,
write('Luas Segitiga'),nl,
write('Masukkan Alas : '),read(A),nl,
write('Masukkan Tinggi : '),read(T),nl,
L is A*T/2,
write('LUAS SEGITIGA : '),write(L),nl,
menu;
PIL=2,nl,
write('Volume Balok'),nl,
write('Masukkan Panjang : '),read(P),nl,
write('Masukkan Lebar : '),read(L),nl,
write('Masukkan Tinggi : '),read(T),nl,
V is P*L*T,
write('VOLUME BALOK : '),write(V),nl,
menu;
PIL=3,nl,
write('Volume Kubus'),nl,
write('Masukkan Sisi : '),read(S),nl,
V is S*S,
write('VOLUME KUBUS : '),write(V),nl,
menu;
PIL=4,nl,
write('Terimakasih'),nl).
Menu Biodata dan Segitiga Angka
Prolog
loopa(A,B):-
(A>0,
loopb(B,1),nl,
C is A-1,
D is B+1,
loopa(C,D);
A=0,nl).
loopb(X,Z):-
( X>0,write(Z),
Y is X-1,
W is Z+1,
loopb(Y,W);
X=0,write('')).
menu :-
write('=====MENU====='),nl,
write('1. Biodata'),nl,
write('2. Segitiga'),nl,
write('3. Keluar'),nl,
write('Masukkan pilihan : '), read(PIL), nl,
(PIL=1,nl,
write('------BIODATA------'),nl,
write('Nama saya : '),read(A),nl,
write('NPM saya : '),read(B),nl,
write('-------------------'),nl,
write('Nama saya : '),write(A),nl,
write('NPM saya : '),write(B),nl,
menu;
PIL=2,nl,
write('Nilai Perulangan : '),read(A),loopa(A,1),
menu;
PIL=3,nl,
write('Terimakasih'),nl).
0 comments: (+add yours?)
Posting Komentar