How to calculate division and multiply in Jasper report

ireportjasper-reports

I have problem when I try to calculate an expression in Jasper.
The error message show after I run the report.

Error filling print... Error evaluating expression :      Source text : new Integer(($F{total_answer}.intValue()) / ($F{total_max_score}.intValue()*100)) 
Can't find the translation for key = time_picker: using default (Time)  Can't find the translation for key = time_picker: using default (Time)  For input string: ""  For input string: ""  java.lang.ArithmeticException: / by zero 

This my code:

new Integer(($F{total_answer}.intValue()) / ($F{total_max_score}.intValue()*100))

Anyone know about this?

Best Answer

here is the solution

how to use divide() method in jasper reports?

And note to check for nullity by assigning the initial value to 0.

${total_answer}.divide( ${total_max_score} )

and you can do the same for multiplication using .multiply()

Related Topic