0

I'm having problems performing math in JSP. I have a line:

double percentage = (useful / nonuseful) * 100;

which is giving me an error, how do I fix this?

Thanks

2
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by eddy556
0
<%
        double useful = 12;
        double nonuseful = 24;
        double percentage = ( useful / nonuseful ) * 100;
    %>
    <%= percentage %>

In this example it will be 50.0 in the JSP page.

0

Okay now I'm getting errors about doubles and integers the values in the database are stored as doubles

Type mismatch: cannot convert from double to int

136: double useful = columns.getDouble("Customer_Useful");
137: double nonuseful = columns.getDouble("Customer_NotUseful");
138: votes = useful + nonuseful;
139: double percentage = (useful / nonuseful) * 100;

0

Can you paste me the whole code. Including variable declaration. Some where in the declaration a variable have been declared int.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.