Hi im trying to add calculations from my database depending on the user request but my float will not work unless its final, how can I get around this?
Code:
float v = (float) 0;
StringBuilder upcoming = new StringBuilder("Upcoming\n\n");
StringBuilder Results = new StringBuilder("Upcoming\n\n");
switchExam.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(!isChecked)
{
for(FAssessment a : assessmentList) {
if(!a.getType().equals("Final"))
{
double d = CalculatePercentage(a.getTotal(),a.getAchieved(),Double.parseDouble(a.getWeight()));
v += (float) d;
}
}
}
else
{
for(FAssessment a : assessmentList) {
double d = CalculatePercentage(a.getTotal(),a.getAchieved(),Double.parseDouble(a.getWeight()));
v += (float) d;
}
}
}
});
This is where I'm getting the error v += (float) d;
Variable 'v' is accessed from within inner class, needs to be final or effectively final