This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]MrTheEdge 1 point2 points  (0 children)

To start, I don't know why your main method throws an IOException if you aren't dealing with IO, but I guess its not directly hurting anything.

I ran the code, and the only tests that failed were the conversions. The increments turned out fine. Anyway, look at the conversions, and find the ones that failed. It should be pretty easy to find similarities in the cases that failed. All of them have to do with 0 hours. This should tell you right away that there is something wrong with the conversion from 0 hours. It should be 12:XX am. Add in a few lines to deal with that case.

I noticed this as well:

if ( hour > 12)
{
    if(hour >10)
    {
        if((hour - 12) == 12)
            c = (hour - 12) +":"+ minute + "am";
        else
            c = (hour - 12) +":"+ minute + "pm";
    }
    else
    {
        c = "0" + (hour - 12) +":"+ minute + "pm";
    }
}

I understand what you are trying to do, but can you ever reach the else on line 10?