Friday, August 24, 2007

Program 1: FizzBuzz

The objective of the first program of this course was quite simple. The program simply had to output every integer from 1 to 100, replacing multiples of 3 with "Fizz", multiples of 5 with "Buzz", and multiples of 3 and 5 with FizzBuzz.

Once I downloaded and opened eclipse (approx. 20min download and 2min unzip), it took very little time to get this program running correctly.

10:05pm - Started new project and began by opening one of my old Java programs to refresh myself on all of the basic syntax (it has been over a year since I've written any java.)

10:19pm - Finished program. It is running correctly and Eclipse was rather easy to use for a program this simple. Here is the very simple and short code:

public class FizzBuz {
public static void main(String [] args)
{
int i;
for(i=1; i<=100; i++)
{
if(i%3==0 && i%5==0)
{
System.out.println("FizzBuzz");
}
else if(i%5==0)
System.out.println("Buzz");
else if(i%3==0)
System.out.println("Fizz");
else
System.out.println(i);
}
}
}

The only Java coding I have previously done was with Notepad (sorry to admit). Even in this sort amount of time I can see many nice features in Eclipse. I particularly like the method listing when you type out a class (like Visual Studios). I will continue to play around with it to get used to some of the features of Eclipse.

No comments: