Saturday, 15 May 2010

Are the brackets used correctly in the equation in java? -



Are the brackets used correctly in the equation in java? -

double y = [(100-totalgrade)*weightcategory]+(totalgrade*x);

is valid equation? wondering if brackets used correctly

no, brackets not used correctly. square brackets ([ ]) reserved accessing array elements.

you want utilize nested parenthesis: double y = ((100-totalgrade)*weightcategory)+(totalgrade*x);

but in equation, alex pointed out:

double y = (100-totalgrade)*weightcategory+totalgrade*x;

is sufficient.

java

No comments:

Post a Comment