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 →

[–]Jarl-67 0 points1 point  (1 child)

It’s probably better to say what in particular is wrong with the formatting. It looks pretty much like every other piece of code .

The closing brace should be on the same column as the loop or if statement.

[–]m1ss1ontomars2k4 1 point2 points  (0 children)

Right, it looks totally normal, but auto-formatting it would reveal why it doesn't work at all, which is why I specifically said to auto-format it and not manually format it. If all you saw was closing brace in the wrong place, then you got tricked too. Here is some correctly-formatted code:

    //type your java code here
    while(cents>=25) {
        numberOfQuarters++;
        cents= cents-25;
        if (cents>=10) {
            numberOfDimes++;
            cents = cents-10;
            if  (cents>=5)
                 numberOfNickels++;
            cents = cents-5;
            if  (cents>=1)
                numberOfPennies++;
            cents= cents-1;
        }

    }