Friday 23 February 2007 @ 2:24 pm
Here are a few lines of code I found in an application that I’m currently maintaining. I don’t know who wrote this code originally.
// Values read from somewhere
int budgetSpent = ...;
int budget = ...;
// Compute percentage of budget spent
int percentage = Math.round(budgetSpent * 100 / budget);
The last line of code is wrong. Can you tell me why? Every Sun Certified Java Programmer should be able to anwer this.
— By Jesper de Jong Comments (6) PermaLink