bank(gebeya,cbe,2,5).
similarIR(4,georgis,abysinia). % bank with similar interest rate in %.
similarIR(4,center,awash).

similarLR(5,gebeya,abysinia). % bank with similar lending rate in %.
similarLR(6,georgis,abysinia).
similarLR(7,center,awash).

start:-write('==============WELCOM GUEST==============='),nl,
write('which bank u want to go?'),nl,
write('u can search using interest rate or lending rate.'),nl, 
write('================go a head================='),nl,
write('Please enter the interest rate: '),nl,   % using interest rate,
read(A),tellinfo1(A),info1(Y),
start2.
%similarIR(A,L,N)
tellinfo1(A):-(similarIR(A,L,N);bank(L,N,A,R)),  % notice if u run alone this code only it display both bank which are simimar interest rate...
write('Bank name: '),write(N),nl,
write('Bank found near: '),write(L),nl.
tellinfo1(A):-!,write('Sorry no bank is/are found on thise interest rate.'),nl,start2,
write('Do you to continue?(y/n)'),tab(1),
		  read(R),(R=y,start).
start2:-write('Or u can search using lending rate?'),nl, % lending rate,
write('Enter lending rate: '),nl,
read(A),tellinfo2(A).

tellinfo2(A):-similarLR(A,L,N),
write('Bank name: '),write(N),nl,
write('Bank found near: '),write(L),nl,profile4(X).
tellinfo2(A):-!,write('Sorry no bank is/are found on thise lending rate.'),nl,
write('Do you to continue?(y/n)'),tab(1),
		  read(R),(R=y,start).

bankmaxIR([IR],IR).  %loop for finding maximum interest rate among given bank.
bankmaxIR([IR|LIST],MAX):-bankmaxIR(LIST,MAX1),(IR>=MAX1, MAX=IR ; IR<MAX1, MAX=MAX1),nl,
info1(MAX).
info1(Y):-similarIR(A,L,N),write('TIPS:'),
write('Maximum interest rate back name : '),tab(1),write(N),write(:),tab(1),write(A),write('%'),nl.

bankminIR([A],A).%loop for finding minimum lending rate among given bank.
bankminIR([A|LIST],MIN):-bankminIR(LIST,MIN0),(A=<MIN0, MIN=A ; A>MIN0, MIN=MIN0),nl,
profile4(MIN).
profile4(X):-similarLR(A,L,N),write('TIPS:'),
write('Minimum lending rate bank name :'),write(N),write(:),write(A),write('%'),nl,bankentry,nl,
write('Do you to continue?(y/n)'),tab(1),
		  read(R),(R=y,start). 
		  
bankentry:-write('if u want to enter new bank and location.'),nl, %which is dynamic 
write('Enter bank location:'),nl,
 	 read(X),nl,banklocation(X,N).
		  
banklocation(X,N):-write('Enter Bank Name:'),nl,
			read(N),
			banklocation(X,N,IR),nl.
banklocation(X,N,IR):-write('Enter Interest Rate in %:'),nl,
                 read(IR),
		        banklocation(X,N,IR,LR).		  
banklocation(X,N,IR,LR):-write('Enter Lending Rate in %:'),nl,
                  read(LR),write('successfully added:'),nl,write('Bank name :'),tab(1),write(N),nl,write('location :'),tab(1),write(X),nl,
				  write('Interest rate in %:'),write(IR),tab(1),write('and'),nl,write('lending rate in % :'),write(LR).