The problem with this code is I'm getting the popularity of an author as 0% (I mean zero percent if the number of borrowed books is 14 and the total number of books borrowed of the selected author is 3 - it should be 21.42%). Why is this happening?
All result are correct except the last one:
Author is 0 % popular (for above given data)
<%
String requestedoprations = request.getParameter("popularity");
if("check".equalsIgnoreCase(requestedoprations)){
int num=LimsHandler.getInstance().popularitycheck(
request.getParameter("selectedauthor"));
if(num!=0){
Limsdetails[] list = LimsHandler.getInstance().libsdetails();
String totbks=list[0].getTot_books();
String totbrwdbk=list[0].getTot_borrowed_bks();
int totbksint=Integer.parseInt(totbks);
int totbrwdbksint=Integer.parseInt(totbrwdbk);
float per=(num/totbrwdbksint)*100;
%>
<font color="brown">
<b>Total No of Books Available in Library is : <%=totbksint %><br></br>
Out of which <%=totbrwdbksint %> are borrowed.<br></br>
<b>No of readers reading Author
<%=request.getParameter("selectedauthor") %>'s book. :
<%=num %></b><br></br>
<b> Author <%=request.getParameter("selectedauthor") %> is <%=per %> %
popular!</b><br></br>
</font>
<%}else{ %>
<h4 align="center">
<font color="red">
<img border="0" src="images/close.PNG" ><br></br>
Oops! some error occurred!
</font>
</h4>
<%
}
out.flush();
%>
<%} %>