Would someone be kind and improve this code
publicclass EvilSearchHeader{
privatestaticvoid calculateHeader(int totalResults,int resultsPerPage,int currentPage){
double totalPagesDbl = ((double)totalResults)/((double)resultsPerPage);
int totalPages = (int)Math.ceil(totalPagesDbl);
if(currentPage >= totalPages){
currentPage = totalPages;
}
resultsPerPage = (resultsPerPage <= totalResults)?resultsPerPage:totalResults;//how many on this page
int endingResult = resultsPerPage * currentPage;
int startingResult = -1;
if(endingResult > totalResults){
startingResult = endingResult - resultsPerPage;
endingResult = totalResults;
}else{
startingResult = endingResult - resultsPerPage;
}
if(startingResult > endingResult){
startingResult = endingResult -1;
}
System.out.println("displaying result "+startingResult+" - "+endingResult+//$NON-NLS-1$ //$NON-NLS-2$
" of "+totalResults+" | on page "+currentPage+" of "+totalPages);//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
publicstaticvoid main(String[] args){
int totalResults = 46;
int resultsPerPage = 5;
int currentPage = 7;
System.out.println("Calculate header for: \"total results\"="+totalResults+" \"current page\"="+currentPage);
calculateHeader(totalResults,resultsPerPage,currentPage);
}
}

