Monday, August 31, 2009

FizzBuzz

From opening eclipse to verifying the correct output of my FizzBuzz program, I took 6 minutes 34 seconds.

PUBLIC class FizzBuzz {

  
PUBLIC static void main(String[] args) {

      
FOR(INT i = 1; i <= 100; i++) {
          
IF ((i % 15) == 0) {
               System.out.println
("FizzBuzz");
          
}
          
ELSE IF ((i % 3) == 0) {
               System.out.println
("Fizz");
          
}
          
ELSE IF ((i % 5) == 0) {
               System.out.println
("Buzz");
          
}
          
ELSE { System.out.println(i); }
       }
      
   }

}


I didn't run into any of the problems that I had when trying writing this program for the first time. Eclipse ran as expected and I was able to write and run the FizzBuzz program quickly. The first time I tried this program in class, I was very rusty in Java, having not used it in a while. I forgot the syntax and was missing parts of the main() function.

The FizzBuzz program has revealed to me that I needed to review my Java.

No comments: