i am getting the sonar qube warning on the below code, actually i know the solution of this but still want know if any another best way to solve that problem ,
public static ProductServiceExpenseModel createModel(ProductServiceExpense entity) {
if (entity == null) {
return null;
}
ProductServiceExpenseModel model = new ProductServiceExpenseModel();
float cost = (float) (entity.getCost() / 100);
//Cast one of the operands of this integer division to a "double".
model.setCost(cost);
model.setProductName(entity.getProductName());
model.setProductExpenseId(entity.getProductExpenseId());
return model;
}
In above method , i get the warning on float cost = (float) (entity.getCost() / 100);
this part please let me know if there is any best approach to handle that , Thanks in advance.