WTF Code moments…

One of my Graduate Assistant responsibilities this semester is grading homeworks for an introductory Java class. As you can imagine, I see alot of bad code. But every once in a while, I run into something really “special”.

The assignment was to write a payroll class, and one of the methods should calculate employees sick days. Every employee gets 1 sick day per 75 hours worked. This is how one of the students tackled the problem:

int totalHoursWorkedTemp = totalHoursWorked;
while(totalHoursWorkedTemp > 75)
{
    totalHoursWorkedTemp = totalHoursWorkedTemp - 75;
    sickDays++;
}
 
return sickDays;

I was about to mark it wrong, but then I realized that this will actually do the job. Awkward, but valid solution.

I don’t know… What’s wrong with sickDays = totalHoursWorked/75 (integer division)? But then again, maybe I’m being a minimalist here. I should be glad that they figured out how a loop works, eh?

Tags: , , , , , , ,

Related Posts:

  • WTF Video Clip of the Week
  • Need a Project
  • WTF of the Week
  • March of Progress
  • Half Assed Error Messages
  • The best part of programming is…
  • In the News: WTF?
  • Great moments in TV history…
  • Awk One Liners
  • Indenting Brackets

  • Leave a Reply

    XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <pre lang=""> <em> <i> <strike> <strong>

    [Quote selected]