Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.


+5 votes

All of the visible tests in problem 2 pass, but it says that my code failed a hidden test. What's wrong?

asked in old_CSC201 by (8 points)

1 Answer

+1 vote

This is the most likely reason. Read the problem carefully. It says that the rounding to 3 decimal digits should happen in function main. You are likely rounding the volume in the computeVolume function before you return the volume.

Why not round in the function? Different programs that might use this computeVolume function may require a different degree of accuracy. By returning the unrounded version, then the calling function can "decide" how much accuracy it needs for the volume.

answered by (8 points)