Here will go through how I chose to solve Assignment 2 from Intro to Programming in Java as taught at MIT. All course related documents and files are linked below.

In this assignment we are tasked with calculating and displaying the total pay of three employees of the hypothetical Foo Corporation. The calculation must adhere to the following rules:

  1. An employee gets paid (hours worked) x (base pay), for each hour up to 40 hours
  2. For every hour over 40, they get overtime = (base pay) x 1.5.
  3. The base pay must not be less than the minimum wage ($8.00 an hour).  If it is, print an error.
  4. If the number of hours is greater than 60, print an error message.

My program must follow these rules.  Additionally the main method cannot contain the calculations.  These must be sent to a separate method and displayed.

Finally the program must evaluate the following three employees:

Employee 1 – Base Pay: $7.50 – Hours Worked: 35
Employee 2 – Base Pay: $8.20 – Hours Worked: 47
Employee 3 – Base Pay: $10.00 – Hours Worked: 73

My solution involved using an if/else and a nested if/elseif/else statement to solve for the rules.

Screenshot 2015-09-02 21.46.51

The source code file for my solution is linked below.  If I made a mistake or if you have a better solution please post it below.

Course Homepage
Assignment PDF
My Solution

In preparation for this post I did a search for Foo Corporation hoping to find a good image to use at the top. It turns out that FooCorp is a real thing and is involved in the free software movement. The founder of the music site, Matt Lee, is a member of FooCorp.


Intro to Programming in Java: Assignment 1

September 2, 2015

In this assignment you are tasked with calculating the location of an object after 10 seconds of free fall under Earth’s gravity.

Read the full article →

Question and Answer by Charles Bukowski

July 21, 2015

he sat naked and drunk in a room of summer
night, running the blade of the knife
under his fingernails, smiling, thinking

Read the full article →

How Self-Driving Cars Will Put Taxis And Parking Lots Out Of Business

June 2, 2014

Inevitability. When the first light bulb turned on the day of the candle was done. I’m not saying if you are a taxi cab driver or parking garage owner you should give up immediately, you’ve definitely got time.  But time, as they say, is not on your side.  Follow me… The car pulls up to […]

Read the full article →

InMotion Hosting

March 26, 2014

Dear Readers, This website for its entire existence has been hosted by InMotion Hosting. Why am I telling you this? Because they rock! Before I even dig into the features they offer I want to highlight their customer service. Are there cheaper web hosts? Of course. Are there web hosts that offer more features? Actually […]

Read the full article →

Syncing your cloud storage with cloudHQ

March 25, 2014

Google Drive has become my go-to service for almost all things cloud. Sure I have a Pogoplug and a Dropbox, but all of my documents and all of my photos are stored through Google’s cloud service. However, despite my heavy Google dependence I still find myself loving Evernote. When I want to casually journal, take […]

Read the full article →

Happy Birthday Professor Tolkien!

January 3, 2013

Today is J. R. R. Tolkien’s birthday!  Celebrate by reading some of his works, eating some lembas bread or other foods from Arda, and don’t forget to smoke some Old Toby with your favorite churchwarden pipe! Click here to learn more about Tolkien. Don’t forget to join in on the annual birthday toast! J. R. […]

Read the full article →

The Principle of Self-Ownership

October 13, 2012
Thumbnail image for The Principle of Self-Ownership

My philosophy is based on the principle of self-ownership. You own your life. To deny this is to imply that another person has a higher claim on your life than you do.

Read the full article →

The Adventures of Jonathan Gullible

July 14, 2012

To say that “The Adventures of Jonathan Gullible” is different from other economics or libertarian books would be a gross understatement. The book is written as a series of parables following the travels of a young man named Jonathan Gullible stranded on the strange island of Corrumpo. This island serves as a setting for a thrashing of every commonly accepted fallacy of government and economics.

Read the full article →

How to minimize your chores, part 2: The Laundry

June 24, 2012

If you do this you will save space on the clothes in your closet. You may even be able to see all of your options. If you do this you will save time you used to spend sorting and folding mountains of laundry. If you do this you will save money because you will buy less clothes and when you do buy clothes you will like them more because they will be better thought out and of higher quality

Read the full article →