I have the following function
private Integer calculateWeeklyValue(String p_Value, String Frequency) {
if (p_Value.length() == 0)
p_Value = "0";
Integer Value = Integer.parseInt(p_Value);
if (Frequency.equals("W"))
return (Integer)Value;
else if (Frequency.equals("F"))
return (Integer)((Value / 2));
else if (Frequency.equals("M"))
return (Integer)((Value * 12) / 52);
else if (Frequency.equals("Q"))
return (Integer)((Value * 4) / 52);
else if (Frequency.equals("Y"))
return (Integer)(Value / 52);
else
return 0;
}
It always returns the calue of the variable “Value” even though it matches the different cases.
for eg. it goes to “return (Integer)((Value * 12) / 52);” but then goes to return 0 and returns “Value”. Might be a stupid question but stuck on this.
Use
int.and check yourValueis always 0.