Tuesday, August 21, 2007

fizzbuzz

So I finally got around to doing the fizzbuzz homework and realized a few things. The first thing is that I've very rusty with java. It's been around 2 years, I think, since I really coded in java and this was a wake up call. I remember a lot of the functions and how to generally code in java but the specific things like the exact syntax eluded me. For example, I forgot that the for loop as ";" as delimiters and it took me a few minutes to figure that out. Stupid, huh?

Another speedbump was using eclipse itself. I'm not used to using an IDE. I generally code by hand and I kept finding myself hitting tab when eclipse would do it for me, throwing off my formatting. It actually took me quite a while just to find out where to type my code. I'm not used to starting a new project, looking for the src folder, creating a new class and finally writing code. I like to just open up note and start coding. I usually deal with where the file goes later, but I will admit that using eclipse is really helpful. Esp, since it list all the functions that matches what you're currently typing. Very helpful if you forget the exact name of the function.

Well here's my code...

public class fizzbuzz {

/**
* @param args
*/
public static void main(String[] args) {
int x;
for(x = 1; x < 101; x++){
if(x%15 == 0) {
System.out.println("fizzbuzz");
}
else {

if(x%5 == 0) {
System.out.println("buzz");
}

else {

if(x%3 == 0) {
System.out.println("fizz");
}

else {
System.out.println(x);
}

}
}
}
}

}

Completion time: 13 mins

I've come to realize that software engineering is like solving a puzzle. it's very creative and it's best to come in with a game plan instead of jst driving into it. I actually enjoy this very much and I think I'm going to really enjoy this class. I'm very anxious to see what else we are going to learn.

No comments: