FizzBuzz

This article describes how I came to the realisation that I had to start JonLandrum.com.

I stumbled upon an article on Coding Horror the other day whilst perusing the web, and it made my stomach turn. Go read it, honestly. Right now. The premise of the article is there are people graduating from colleges and universities with degrees in Computer Science who can neither read nor write one single line of code.

And not just Associates or Bachelors, no. Full-fledged Masters and Doctorates who don’t know a lick of code, but they’ve earned the highest attainable degree in the field of computing. Granted, there’s definitely a philosophical side to Computer Science, and there are many Computer Science programs in academia that only focus on that end; it is, after all, a science. But if you, the applicant, are applying for a coding job, at least have the wit to familiarize yourself with the language first. If all you know is the science of computing and not the languages thereof, apply for one of those jobs instead.

To weed these codeless candidates out, hiring managers in many shops have taken to giving simple programming assignments to candidates. The one mentioned in the article above is called “FizzBuzz”. Here is my version, written in Java, that I whipped up in about five minutes. It is, quite literally, a Freshman’s problem. I won’t lie, I was a bit insulted at how easy the assignment is. I know you’re not supposed to post the answer. I understand that it’s not the point, that the point is we shouldn’t need FizzBuzz challenges. But I took that article as a personal affront. I had to prove myself, no matter how trivial the test.

“I am not one of them.”

There’s much more code to follow. FizzBuzz is just the beginning.

~Jonathan

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// ****************************************************
// Programmer:           Jonathan Landrum
// Date:                 23 January 2012
// Class:                Comp. Sci. 101 (Seriously)
// ****************************************************
// Program:              FizzBuzz.java
// Purpose:              To prove that I can program.
// Assumptions:          A lot, apparently.
// ****************************************************
 
import java.util.Scanner;
 
public class FizzBuzz {
	public static void main (String[] args) {
 
		// --------------------------------------------
		// Variables
		// --------------------------------------------
		int	c = 1;
		String	response;
		Scanner scan = new Scanner(System.in);
 
		// --------------------------------------------
		// Introduce the program
		// --------------------------------------------
		System.out.println ("-------------------------------------");
		System.out.println ("-             Fizz Buzz             -");
		System.out.println ("-------------------------------------");
		System.out.println ();
		System.out.println ("This program reproduces a traditional");
		System.out.println ("British children's counting game, but");
		System.out.println ("more specifically, it represents a");
		System.out.println ("coding challenge.");
		System.out.println ();
		System.out.print   ("Would you like to continue? [Y/N] ");
 
			response   = scan.nextLine();
 
		// --------------------------------------------
		// Main block
		// --------------------------------------------
		while (response.charAt(0) == 'y' || response.charAt(0) == 'Y') {
			while (c <= 100) {
				if (c > 3) {
					if (c % 3 == 0 && c % 5 == 0) {
						System.out.println ("FizzBuzz");
					} else if (c % 3 == 0) {
						System.out.println ("Fizz");
					} else if (c % 5 == 0) {
						System.out.println ("Buzz");
					} else {
						System.out.println (c);
					} // End test if block
				} else {
					System.out.println (c);
				} // End print if block
				c++;
			} // End main while block
 
			System.out.println ("-------------------------------------");
			System.out.println ("Process complete.");
			System.out.print   ("Would you like to continue? [Y/N] ");
 
				response   = scan.nextLine();
 
		} // End while
		System.out.println ();
		System.out.println ("\\\\//_ Live long and prosper.");
		} // End main
} // End FizzBuzz

Jonathan Landrum
Jonathan Landrum is a full-time husband and student, and a part-time research assistant and IT guy. He both works and studies at Mississippi College, where he is pursuing a Bachelor of Science in Computer Science.

9 thoughts on “FizzBuzz

  1. Pingback: Sum of Threes and Fives :: Jonathan Landrum

  2. Pingback: Finding the Least Common Multiple Using Euclid’s Algorithm and C++ :: Jonathan Landrum

Name:
Email:
Message:

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">