<lab xmlns="http://www.web-ide.org/namespaces/labs/1" name="Facebook: Functions">
  <description>
      This is an introductory lab on functions in C using the following scenario:
      Facebook has hired you to help write programs that interact with the user and his or her friends. 
      Your boss has asked you to create an age calculator to be used when a user registers for the 
      website. 
   </description>
  <step name="Function Basics">
      Let's introduce a few basics about functions.  This may be a good review if you recently learned about functions.  
      Vocabulary terms will be highlighted in bold and italics, then reviewed at the bottom.<br /><br />
      
      Here is an example <b>
    <i>function definition</i>
  </b>:
      <code> 
      double yardsToMeters(int yards)
      {
         return yards * 0.9144;
      }
      </code><dl>
    <dt>"double" is the <b>
      <i>return type</i>
    </b></dt>
    <dt>"yardsToMeters" is the <b>
      <i>function name</i>
    </b></dt>
    <dt>"yards" is the <b>
      <i>parameter</i>
    </b>; "yards" is of <b>
      <i>type</i>
    </b> "int"</dt>
    <dt>the <b>
      <i>function body</i>
    </b> consists of everything inside the curly brackets</dt>
  </dl><dl>
    <dt>Here is an example use of the function or <b>
      <i>function call</i>
    </b>:</dt>
    <dd><code>
        yardsToMeters(4);
        </code>
    </dd>
    <dt>This function call would return 3.6576</dt>
  </dl><dl>
    <dt>When a function returns something, you need to use the value it returns.  You could store the function's return value in a <b>
      <i>variable</i>
    </b> like this:</dt>
    <dd>
    <code>
    double answer = yardsToMeters(4);
    </code>
    </dd>
    <dt>In the above example, the variable "answer" would be assigned the value of 3.6576</dt>
    <dt>Or, you could use the function's return value as the parameter in another function call, like this:</dt>
    <dd>
    <code>
    someFunctionThatAcceptsMeters(yardsToMeters(4))
    </code>
    </dd>
    <dt>or</dt>
    <dd>
    <code>
    printf("4 yards is equivalent to %.3f meters.", yardsToMeters(4));
    </code>
    </dd>
  </dl><b>Vocabulary Review:</b><br /><ul>
    <li>A function definition has a return type, name, set of parameters enclosed in a set of parenthesis, and a body enclosed in a set of curly braces.</li>
    <li>The first line of a function definition (i.e. all but the function body) is sometimes called the <b>
      <i>function signature</i>
    </b> or <b>
      <i>operation signature</i>
    </b>.</li>
    <li>A function's return type and parameters can be any data type.  The built-in or primitive data types that we will work with are: "short", "int", "long", "float", "double", "char"</li>
    <li>If a function does not have any parameters, you use the keyword "void" in place of a parameter list.</li>
    <li>If a function does not return anything, you use the keyword "void" as the return type.  Functions that don't return anything are usually called <b>
      <i>procedures</i>
    </b>.</li>
    <li>A function name can be any word consisting of letters, digits, and _.  Function names (and variable names) cannot begin with a digit.</li>
    <li>A function is only defined once, but it can be called many times.</li>
    <li>When you call a function, you pass in values to the parameters.</li>
  </ul></step>
  <step name="Age Calculator- Basic Information" buttonName="Check">
      Suppose Facebook wants you to create an age calculator that will approximate age based on a given birth year 
      and the current year.  Let's walk through creating a function to do this.<br /><br />
      Based on this brief description, how many parameters will your function need?<br /><segment width="200" id="parameters" height="1" /><evaluator name="regex" labid="Facebook: Functions" href="evaluator://RegExEvaluator">
    <arg>
      <name>regex</name>
      <value>^\s*2\s*$</value>
    </arg>
    <arg>
      <name>failed-message</name>
      <value>I'm sorry, that is not the right number of parameters.</value>
    </arg>
    <arg>
      <name>success-message</name>
      <value>You got the right number of parameters.</value>
    </arg>
    <segid>
      <id>parameters</id>
    </segid>
  </evaluator><hint /><br />
      What is the return type of your function?<br /><segment width="200" id="returnType" height="1" />
<evaluator name="regex" labid="Facebook: Functions" href="evaluator://RegExEvaluator">
    <arg>
      <name>regex</name>
      <value>^\s*int\s*$</value>
    </arg>
    <arg>
      <name>failed-message</name>
      <value>I'm sorry that is not the correct return type. Your return type should be one of the following:              void, int, double, char</value>
    </arg>
    <arg>
      <name>success-message</name>
      <value>That's the correct return type.  Good Job!</value>
    </arg>
    <segid>
      <id>returnType</id>
    </segid>
  </evaluator><hint /></step>
  <step name="Age Calculator- Function Signature" buttonName="Check"><dependency stepName="Age Calculator- Basic Information" /> 
      For the purpose of this exercise we will name our function <i>getApproxAge</i>
      and name our parameters <i>birthYear</i> and <i>curYear</i> in that order. <br /><br />

      Finish the first line of the function, also known as the function header or signature. 
      <i>Remember you need the return type, function name, and parameters.</i><segment width="400" id="firstLine" height="1">     ( , )
</segment>
<!-- <evaluator name="regex" labid="Facebook: Functions" href="evaluator://RegExEvaluator">
    <arg>
      <name>regex</name>
      <value>^\s*$</value>
    </arg>
    <arg>
      <name>failed-message</name>
      <value>It looks like you deleted everything.  You need to type the function signature including the return type, function name, and parameters in the box above. </value>
    </arg>
    <arg> <name>success-message</name> <value /> </arg>
    <segid> <id>firstLine</id> </segid>
  </evaluator>
-->
<evaluator name="regex" labid="Facebook: Functions" href="evaluator://RegExEvaluator">
    <arg>
      <name>regex</name>
      <value>^\s*\(\s*\s*,\s*\)\s*$</value>
    </arg>
    <arg>
      <name>failed-message</name>
      <value>It doesn\'t look like you entered anything new.  You need to type the return type, function name, and parameters in the box above.</value>
    </arg>
    <arg> <name>success-message</name> <value /> </arg>
    <segid> <id>firstLine</id> </segid>
  </evaluator>
<evaluator name="regex" labid="Facebook: Functions" href="evaluator://RegExEvaluator">
    <arg>
      <name>regex</name>
      <value>^\s*getApproxAge\s*\([\w\s]*\s*$</value>
    </arg>
    <arg>
      <name>failed-message</name>
      <value>It looks like you got the function name but forgot the return data type.</value>
    </arg>
    <arg> <name>success-message</name> <value /> </arg>
    <segid> <id>firstLine</id> </segid>
  </evaluator>
<evaluator name="regex" labid="Facebook: Functions" href="evaluator://RegExEvaluator">
    <arg>
      <name>regex</name>
      <value>^\s*[^\(]*\(\s*birthYear[\w\s]*$</value>
    </arg>
    <arg>
      <name>failed-message</name>
      <value>Don't forget the parameter data types.</value>
    </arg>
    <arg> <name>success-message</name> <value /> </arg>
    <segid> <id>firstLine</id> </segid>
  </evaluator>
<evaluator name="regex" labid="Facebook: Functions" href="evaluator://RegExEvaluator">
    <arg>
      <name>regex</name>
      <value>^\s*[^,]*,\s*curYear\s*\)\s*$</value>
    </arg>
    <arg>
      <name>failed-message</name>
      <value>Don't forget the parameter data types.</value>
    </arg>
    <arg> <name>success-message</name> <value /> </arg>
    <segid> <id>firstLine</id> </segid>
  </evaluator>
<evaluator name="regex" labid="Facebook: Functions" href="evaluator://RegExEvaluator">
    <arg>
      <name>regex</name>
      <value>^\s*[^\(]*\(\s*int\s*,[\w\s]*$</value>
    </arg>
    <arg>
      <name>failed-message</name>
      <value>Don't forget the parameter names.</value>
    </arg>
    <arg> <name>success-message</name> <value /> </arg>
    <segid> <id>firstLine</id> </segid>
  </evaluator>
<evaluator name="regex" labid="Facebook: Functions" href="evaluator://RegExEvaluator">
    <arg>
      <name>regex</name>
      <value>^\s*[^,]*,\s*int\s*\)\s*$</value>
    </arg>
    <arg>
      <name>failed-message</name>
      <value>Don't forget the parameter names.</value>
    </arg>
    <arg> <name>success-message</name> <value /> </arg>
    <segid> <id>firstLine</id> </segid>
  </evaluator>
<evaluator name="regex" labid="Facebook: Functions" href="evaluator://RegExEvaluator">
    <arg>
      <name>regex</name>
      <value>^\s*int\s*\(\s*,\s*\)\s*$</value>
    </arg>
    <arg>
      <name>failed-message</name>
      <value>You got the return data type.  Now add the function name and parameters.</value>
    </arg>
    <arg> <name>success-message</name> <value /> </arg>
    <segid> <id>firstLine</id> </segid>
  </evaluator>
<evaluator name="regex" labid="Facebook: Functions" href="evaluator://RegExEvaluator">
    <arg>
      <name>regex</name>
      <value>^\s*int\s*getApproxAge\s*\(\s*,\s*\)\s*$</value>
    </arg>
    <arg>
      <name>failed-message</name>
      <value>You got the function name and return data type.  Now add the parameters.</value>
    </arg>
    <arg> <name>success-message</name> <value /> </arg>
    <segid> <id>firstLine</id> </segid>
  </evaluator>
<evaluator name="regex" labid="Facebook: Functions" href="evaluator://RegExEvaluator">
    <arg>
      <name>regex</name>
      <value>^\s*int\s*getApproxAge\s*\(\s*int\s*birthYear\s*,\s*\)\s*$</value>
    </arg>
    <arg>
      <name>failed-message</name>
      <value>You are getting close.  Now add the second parameter.</value>
    </arg>
    <arg> <name>success-message</name> <value /> </arg>
    <segid> <id>firstLine</id> </segid>
  </evaluator>
<evaluator name="regex" labid="Facebook: Functions" href="evaluator://RegExEvaluator">
    <arg>
      <name>regex</name>
      <value>^\s*int\s*getApproxAge\s*\(\s*,\s*int\s*curYear\s*\)\s*$</value>
    </arg>
    <arg>
      <name>failed-message</name>
      <value>You are getting close.  Now add the first parameter.</value>
    </arg>
    <arg> <name>success-message</name> <value /> </arg>
    <segid> <id>firstLine</id> </segid>
  </evaluator>
<evaluator name="regex" labid="Facebook: Functions" href="evaluator://RegExEvaluator">
    <arg>
      <name>regex</name>
      <value>^\s*int\s*getApproxAge\s*\(\s*int\s*birthYear\s*,\s*int\s*curYear\s*\)\s*$</value>
    </arg>
    <arg>
      <name>failed-message</name>
      <value></value>
    </arg>
    <arg> <name>success-message</name> <value>Good Job!</value> </arg>
    <segid> <id>firstLine</id> </segid>
  </evaluator>
</step>
  <step name="Age Calculator- Examples" buttonName="Check"><dependency stepName="Age Calculator- Function Signature" /> 
      Now let's write some examples for our function. <br />

      Enter values for the parameters, and corresponding expected return values to predict the output of our function.
      Remember that we are just approximating age, so don't worry about what month it is and whether the birthday
      has not yet occurred.<br />
      The first row of the table has been completed for you as an example.  Fill in the remaining rows.

      <labtable rows="5" cols="3" border="1">
    <add>
      <b>Birth Year</b>
    </add>
    <add>
      <b>Current Year</b>
    </add>
    <add>
      <b>Expected Output</b>
    </add>
    <add>
            1990
         </add>
    <add>
            2010
         </add>
    <add>
            20
         </add>
    <add>
      <segment width="50" id="test1a" height="1" />
    </add>
    <add>
      <segment width="50" id="test1b" height="1" />
    </add>
    <add>
      <segment width="50" id="test1c" height="1" />
    </add>
    <add>
      <segment width="50" id="test2a" height="1" />
    </add>
    <add>
      <segment width="50" id="test2b" height="1" />
    </add>
    <add>
      <segment width="50" id="test2c" height="1" />
    </add>
    <add>
      <segment width="50" id="test3a" height="1" />
    </add>
    <add>
      <segment width="50" id="test3b" height="1" />
    </add>
    <add>
      <segment width="50" id="test3c" height="1" />
    </add>
  </labtable><evaluator name="TestEval" labid="Facebook: Functions" href="evaluator://ArithmeticEvaluator">
    <arg>
      <name>equation</name>
      <value>test1b - test1a</value>
    </arg>
    <arg>
      <name>expected</name>
      <value>test1c</value>
    </arg>
    <arg>
      <name>failed-message</name>
      <value>I'm sorry, your 1st row of input is incorrect.</value>
    </arg>
    <arg>
      <name>success-message</name>
      <value />
    </arg>
    <segid>
      <id>test1a</id>
    </segid>
    <segid>
      <id>test1b</id>
    </segid>
    <segid>
      <id>test1c</id>
    </segid>
  </evaluator><hint /><evaluator name="TestEval" labid="Facebook: Functions" href="evaluator://ArithmeticEvaluator">
    <arg>
      <name>equation</name>
      <value>test2b - test2a</value>
    </arg>
    <arg>
      <name>expected</name>
      <value>test2c</value>
    </arg>
    <arg>
      <name>failed-message</name>
      <value>I'm sorry, your 2nd row of input is incorrect.</value>
    </arg>
    <arg>
      <name>success-message</name>
      <value />
    </arg>
    <segid>
      <id>test2a</id>
    </segid>
    <segid>
      <id>test2b</id>
    </segid>
    <segid>
      <id>test2c</id>
    </segid>
  </evaluator><hint /><evaluator name="TestEval" labid="Facebook: Functions" href="evaluator://ArithmeticEvaluator">
    <arg>
      <name>equation</name>
      <value>test3b - test3a</value>
    </arg>
    <arg>
      <name>expected</name>
      <value>test3c</value>
    </arg>
    <arg>
      <name>failed-message</name>
      <value>I'm sorry, your 3rd row of input is incorrect.</value>
    </arg>
    <arg>
      <name>success-message</name>
      <value>Good Job!</value>
    </arg>
    <segid>
      <id>test3a</id>
    </segid>
    <segid>
      <id>test3b</id>
    </segid>
    <segid>
      <id>test3c</id>
    </segid>
  </evaluator><hint /></step>
  <step name="Age Calculator- Tests" buttonName="Check"><dependency stepName="Age Calculator- Examples" /> 
      Let's convert some of your examples into test cases with function calls.<br />  
      We will use a special function named "checkit_int" that knows how to run tests for us.  
      This "checkit_int" function is already defined for you in a library called "checkit.h".
      There are many forms of "checkit" for many different data types.  
      For instance, there is "checkit_double", "checkit_int", "checkit_char", and "checkit_string".
      In general, you pass two values to "checkit_int": an expected value and an actual value.  <br />
      For example, here are some tests that should pass:
      <code>
        checkit_int(6, 2*3)
        checkit_char('c', 'c')
        checkit_double(2.5, 5 / 2)
      </code><br />
      Here are some silly tests that should fail (you would never write tests like this because they don't make any sense):

      <code>
        checkit_int(7, 2*3)
        checkit_char('c', 'd')
      </code><br />
      As you will learn later, computers handle floating point numbers in an interesting way.  As a result, we normally 
      check to see if two double's are close rather than exactly equal.  The question is "how close?"  
      The function checkit_double uses a delta (a positive number that indicates "how close" two numbers need to be to be considered equal).  Here are some examples:
      <br />
      Now, let's create some tests with checkit_int for your getApproxAge function.
      <labtable rows="6" cols="6" border="1">
    <add>Test #</add>
    <add />
    <add>Expected Value</add>
    <add />
    <add>Actual Value</add>
    <add />
    <add>1</add>
    <add>checkit_int(</add>
    <add>20</add>
    <add> , </add>
    <add>getApproxAge(1990,2010)</add>
    <add> ) </add>
    <add>2</add>
    <add>checkit_int(</add>
    <add>
      <segment width="50" id="testExpected2a" height="1" />
    </add>
    <add> , </add>
    <add>
      <segment width="150" id="testActual2a" height="1" />
    </add>
    <add> ) </add>
    <add>3</add>
    <add>checkit_int(</add>
    <add>
      <segment width="50" id="testExpected3a" height="1" />
    </add>
    <add> , </add>
    <add>
      <segment width="150" id="testActual3a" height="1" />
    </add>
    <add> ) </add>
    <add>4</add>
    <add>checkit_int(</add>
    <add>
      <segment width="50" id="testExpected4a" height="1" />
    </add>
    <add> , </add>
    <add>
      <segment width="150" id="testActual4a" height="1" />
    </add>
    <add> ) </add>
    <add>5</add>
    <add>checkit_int(</add>
    <add>
      <segment width="50" id="testExpected5a" height="1" />
    </add>
    <add> , </add>
    <add>
      <segment width="150" id="testActual5a" height="1" />
    </add>
    <add> ) </add>
  </labtable><segment width="0" id="empty2" height="0">

<evaluator name="C Evaluator" labid="Facebook: Functions" href="http://evaluators.web-ide.org/webide/evaluators/CEvaluator/CEvaluator.php">
    <arg>
      <name>functionCode</name>
        <value>int getApproxAge(int birthYear, int curYear) {           return curYear - birthYear;         }</value>
    </arg>
    <arg>
      <name>functionCall</name>
      <value>@testActual2a</value>
    </arg>
    <arg>
      <name>expectedOutput</name>
      <value>@testExpected2a</value>
    </arg>
      <arg>
        <name>smessage</name>
        <value>Good job, your row 2 test passed!</value>
      </arg>
      <arg>
        <name>fmessage</name>
        <value>I'm sorry, your row 2 test failed.</value>
      </arg>
      <segid>
        <id>testExpected2a</id>
      </segid>
      <segid>
        <id>testActual2a</id>
      </segid>
    </evaluator>
<evaluator name="C Evaluator" labid="Facebook: Functions" href="http://evaluators.web-ide.org/webide/evaluators/CEvaluator/CEvaluator.php">
    <arg>
      <name>functionCode</name>
        <value>int getApproxAge(int birthYear, int curYear) {           return curYear - birthYear;         }</value>
    </arg>
    <arg>
      <name>functionCall</name>
      <value>@testActual3a</value>
    </arg>
    <arg>
      <name>expectedOutput</name>
      <value>@testExpected3a</value>
    </arg>
      <arg>
        <name>smessage</name>
        <value>Good job, your row 3 test passed!</value>
      </arg>
      <arg>
        <name>fmessage</name>
        <value>I'm sorry, your row 3 test failed.</value>
      </arg>
      <segid>
        <id>testExpected3a</id>
      </segid>
      <segid>
        <id>testActual3a</id>
      </segid>
    </evaluator>
<evaluator name="C Evaluator" labid="Facebook: Functions" href="http://evaluators.web-ide.org/webide/evaluators/CEvaluator/CEvaluator.php">
    <arg>
      <name>functionCode</name>
        <value>int getApproxAge(int birthYear, int curYear) {           return curYear - birthYear;         }</value>
    </arg>
    <arg>
      <name>functionCall</name>
      <value>@testActual4a</value>
    </arg>
    <arg>
      <name>expectedOutput</name>
      <value>@testExpected4a</value>
    </arg>
      <arg>
        <name>smessage</name>
        <value>Good job, your row 4 test passed!</value>
      </arg>
      <arg>
        <name>fmessage</name>
        <value>I'm sorry, your row 4 test failed.</value>
      </arg>
      <segid>
        <id>testExpected4a</id>
      </segid>
      <segid>
        <id>testActual4a</id>
      </segid>
    </evaluator>
<evaluator name="C Evaluator" labid="Facebook: Functions" href="http://evaluators.web-ide.org/webide/evaluators/CEvaluator/CEvaluator.php">
    <arg>
      <name>functionCode</name>
        <value>int getApproxAge(int birthYear, int curYear) {           return curYear - birthYear;         }</value>
    </arg>
    <arg>
      <name>functionCall</name>
      <value>@testActual5a</value>
    </arg>
    <arg>
      <name>expectedOutput</name>
      <value>@testExpected5a</value>
    </arg>
      <arg>
        <name>smessage</name>
        <value>Good job, your row 5 test passed!</value>
      </arg>
      <arg>
        <name>fmessage</name>
        <value>I'm sorry, your row 5 test failed.</value>
      </arg>
      <segid>
        <id>testExpected5a</id>
      </segid>
      <segid>
        <id>testActual5a</id>
      </segid>
    </evaluator>
  </segment></step>
  <step name="Age Calculator- Part 2" buttonName="Check"><dependency stepName="Age Calculator- Tests" /> <br />
      Now finish the body of our function.<br /><b>The body should calculate the approximate age, based on our two parameters</b>.
      Try to do it in a single return statement.<br /><segment width="600" id="functionbody" height="150">
int getApproxAge(int birthYear, int curYear)
{
}
      </segment>
<evaluator name="C Evaluator" labid="Facebook: Functions" href="http://evaluators.web-ide.org/webide/evaluators/CEvaluator/CEvaluator.php">
    <arg>
      <name>functionCode</name>
      <value>@functionbody</value>
    </arg>
    <arg>
      <name>functionCall</name>
      <value>getApproxAge(1990,2010)</value>
    </arg>
    <arg>
      <name>expectedOutput</name>
      <value>20</value>
    </arg>
      <arg>
        <name>smessage</name>
        <value>Good job, your code passed a test!</value>
      </arg>
      <arg>
        <name>fmessage</name>
        <value>I'm sorry, your failed a test.</value>
      </arg>
      <segid>
        <id>functionbody</id>
      </segid>
    </evaluator>
<evaluator name="C Evaluator" labid="Facebook: Functions" href="http://evaluators.web-ide.org/webide/evaluators/CEvaluator/CEvaluator.php">
    <arg>
      <name>functionCode</name>
      <value>@functionbody</value>
    </arg>
    <arg>
      <name>functionCall</name>
      <value>getApproxAge(1990,2015)</value>
    </arg>
    <arg>
      <name>expectedOutput</name>
      <value>25</value>
    </arg>
      <arg>
        <name>smessage</name>
        <value>Good job, your code passed a test!</value>
      </arg>
      <arg>
        <name>fmessage</name>
        <value>I'm sorry, your failed a test.</value>
      </arg>
      <segid>
        <id>functionbody</id>
      </segid>
    </evaluator>
<evaluator name="C Evaluator" labid="Facebook: Functions" href="http://evaluators.web-ide.org/webide/evaluators/CEvaluator/CEvaluator.php">
    <arg>
      <name>functionCode</name>
      <value>@functionbody</value>
    </arg>
    <arg>
      <name>functionCall</name>
      <value>getApproxAge(2006,2008)</value>
    </arg>
    <arg>
      <name>expectedOutput</name>
      <value>2</value>
    </arg>
      <arg>
        <name>smessage</name>
        <value>Good job, your code passed a test!</value>
      </arg>
      <arg>
        <name>fmessage</name>
        <value>I'm sorry, your failed a test.</value>
      </arg>
      <segid>
        <id>functionbody</id>
      </segid>
    </evaluator>
  </step>
  <step name="Better Calculator- Basic Information" buttonName="Check"><dependency stepName="Age Calculator- Part 2" /> 
      Great job! As you probably noticed, our age approximating function isn't very accurate because it only uses years.
      What if someone was born in December, 1990, but it is currently November 2010?  Our age approximator says they are 20,
      but they are really only 19 years old.   <br /><br />

      Let's make a better approximation of someone's age by using both the year and the month (don't worry, we will add in the day later).<br />
      For the purpose of this exercise we will name this new function <i>getApproxAge2</i>.<br /><br />

      Your return type is still an integer, but <b>how many parameters will your new function need?</b><br /><segment width="300" id="parameters2" height="1" /><evaluator name="regex" labid="Facebook: Functions" href="evaluator://RegExEvaluator">
    <arg>
      <name>regex</name>
      <value>^\s*4\s*$</value>
    </arg>
    <arg>
      <name>failed-message</name>
      <value>I'm sorry that is not the right number of parameters.  Remember we are using a year and month for both the current year and the birth year.</value>
    </arg>
    <arg>
      <name>success-message</name>
      <value>Good Job!</value>
    </arg>
    <segid>
      <id>parameters2</id>
    </segid>
  </evaluator><hint /></step>
  <step name="Better Age Approximation- Tests" buttonName="Check"><dependency stepName="Better Calculator- Basic Information" />
      Let's write some tests for our function. <br />
      The first row has been filled out for you as an example.<br /><labtable rows="5" cols="5" border="1">
    <add>
      <b>Birth Year</b>
    </add>
    <add>
      <b>Current Year</b>
    </add>
    <add>
      <b>Birth Month</b>
    </add>
    <add>
      <b>Current Month</b>
    </add>
    <add>
      <b>Expected Output</b>
    </add>
    <add> 1990            </add>
    <add> 2010            </add>
    <add> 6           </add>
    <add> 7         </add>
    <add> 20         </add>
    <add>
      <segment width="50" id="test4a" height="1" />
    </add>
    <add>
      <segment width="50" id="test4b" height="1" />
    </add>
    <add>
      <segment width="50" id="test4c" height="1" />
    </add>
    <add>
      <segment width="50" id="test4d" height="1" />
    </add>
    <add>
      <segment width="50" id="test4e" height="1" />
    </add>
    <add>
      <segment width="50" id="test5a" height="1" />
    </add>
    <add>
      <segment width="50" id="test5b" height="1" />
    </add>
    <add>
      <segment width="50" id="test5c" height="1" />
    </add>
    <add>
      <segment width="50" id="test5d" height="1" />
    </add>
    <add>
      <segment width="50" id="test5e" height="1" />
    </add>
    <add>
      <segment width="50" id="test6a" height="1" />
    </add>
    <add>
      <segment width="50" id="test6b" height="1" />
    </add>
    <add>
      <segment width="50" id="test6c" height="1" />
    </add>
    <add>
      <segment width="50" id="test6d" height="1" />
    </add>
    <add>
      <segment width="50" id="test6e" height="1" />
    </add>
  </labtable>
<evaluator name="C Evaluator" labid="Facebook: Functions" href="http://evaluators.web-ide.org/webide/evaluators/CEvaluator/CEvaluator.php">
    <arg>
      <name>functionCode</name>
      <value>int ageCalculator(int bYear, int cYear, int bMonth, int cMonth)                                      {                                         if(bMonth == cMonth)                                         {                                            return cYear-bYear;                                         }                                         else                                         {                                            return (cYear-bYear) - (bMonth/cMonth);                                         }                                      }</value>
    </arg>
    <arg>
      <name>functionCall</name>
      <value>ageCalculator(@test4a, @test4b, @test4c, @test4d)</value>
    </arg>
    <arg>
      <name>expectedOutput</name>
      <value>@test4e</value>
    </arg>
    <arg>
      <name>smessage</name>
      <value />
    </arg>
    <arg>
      <name>fmessage</name>
      <value>I'm sorry, the 2nd row is incorrect.</value>
    </arg>
    <segid>
      <id>test4a</id>
    </segid>
    <segid>
      <id>test4b</id>
    </segid>
    <segid>
      <id>test4c</id>
    </segid>
    <segid>
      <id>test4d</id>
    </segid>
    <segid>
      <id>test4e</id>
    </segid>
  </evaluator><hint /><evaluator name="C Evaluator" labid="Facebook: Functions" href="http://evaluators.web-ide.org/webide/evaluators/CEvaluator/CEvaluator.php">
    <arg>
      <name>functionCode</name>
      <value>int ageCalculator(int bYear, int cYear, int bMonth, int cMonth)                                      {                                         if(bMonth == cMonth)                                         {                                            return cYear-bYear;                                         }                                         else                                         {                                            return (cYear-bYear) - (bMonth/cMonth);                                         }                                      }</value>
    </arg>
    <arg>
      <name>functionCall</name>
      <value>ageCalculator(@test5a, @test5b, @test5c, @test5d)</value>
    </arg>
    <arg>
      <name>expectedOutput</name>
      <value>@test5e</value>
    </arg>
    <arg>
      <name>smessage</name>
      <value />
    </arg>
    <arg>
      <name>fmessage</name>
      <value>I'm sorry, the 3rd row is incorrect.</value>
    </arg>
    <segid>
      <id>test5a</id>
    </segid>
    <segid>
      <id>test5b</id>
    </segid>
    <segid>
      <id>test5c</id>
    </segid>
    <segid>
      <id>test5d</id>
    </segid>
    <segid>
      <id>test5e</id>
    </segid>
  </evaluator><hint /><evaluator name="C Evaluator" labid="Facebook: Functions" href="http://evaluators.web-ide.org/webide/evaluators/CEvaluator/CEvaluator.php">
    <arg>
      <name>functionCode</name>
      <value>int ageCalculator(int bYear, int cYear, int bMonth, int cMonth)                                      {                                         if(bMonth == cMonth)                                         {                                            return cYear-bYear;                                         }                                         else                                         {                                            return (cYear-bYear) - (bMonth/cMonth);                                         }                                      }</value>
    </arg>
    <arg>
      <name>functionCall</name>
      <value>ageCalculator(@test6a, @test6b, @test6c, @test6d)</value>
    </arg>
    <arg>
      <name>expectedOutput</name>
      <value>@test6e</value>
    </arg>
    <arg>
      <name>smessage</name>
      <value>Good Job!</value>
    </arg>
    <arg>
      <name>fmessage</name>
      <value>I'm sorry, the 4th row is incorrect.</value>
    </arg>
    <segid>
      <id>test6a</id>
    </segid>
    <segid>
      <id>test6b</id>
    </segid>
    <segid>
      <id>test6c</id>
    </segid>
    <segid>
      <id>test6d</id>
    </segid>
    <segid>
      <id>test6e</id>
    </segid>
  </evaluator><hint /></step>
  <step name="Better Age Approximation Calculator" buttonName="Check"><dependency stepName="Better Age Approximation- Tests" /> 
      Now write the function <i>getApproxAge2</i> to calculate an approximate age using the birth and current months and years. 
      Refer to the parameters as <i>birthYear</i>, <i>curYear</i>, <i>birthMonth</i> and <i>curMonth</i> in that order. <br /><br />
<segment width="400" id="betterAge" height="300" /><evaluator name="C Evaluator" labid="Facebook: Functions" href="http://evaluators.web-ide.org/webide/evaluators/CEvaluator/CEvaluator.php">
    <arg>
      <name>functionCode</name>
    <value>@betterAge</value>
    </arg>
    <arg>
      <name>functionCall</name>
      <value>getApproxAge2(1980, 2010, 6, 1)</value>
    </arg>
    <arg>
      <name>expectedOutput</name>
      <value>29</value>
    </arg>
    <arg>
      <name>smessage</name>
      <value>Good Job!</value>
    </arg>
    <arg>
      <name>fmessage</name>
      <value>I'm sorry, your better age calculator does not work properly. Please review the                    specifications.</value>
    </arg>
    <segid>
      <id>betterAge</id>
    </segid>
  </evaluator><hint />
</step>
  <step name="Exact Age Calculator- Basic Information" buttonName="Check"><dependency stepName="Better Age Approximation Calculator" /> 
      We will now write a function that will calculate the exact age of the person. 
      Since we are now including the birth day and current day...
      <br /><b>How many parameters will your function need?</b><segment width="50" id="parameters4" height="1" /><evaluator name="regex" labid="Facebook: Functions" href="evaluator://RegExEvaluator">
    <arg>
      <name>regex</name>
      <value>^\s*6\s*$</value>
    </arg>
    <arg>
      <name>failed-message</name>
      <value>I'm sorry that is not the right number of parameters.</value>
    </arg>
    <arg>
      <name>success-message</name>
      <value>Good Job!</value>
    </arg>
    <segid>
      <id>parameters4</id>
    </segid>
  </evaluator><hint /></step>
  <step name="Exact Age Calculator- Tests"><dependency stepName="Exact Age Calculator- Basic Information" /> 
      First let's write some tests for our function.<br />
      Complete the following table. 
      Note that some of the entries have been completed or partially completed for you.

      <labtable rows="7" cols="7" border="1">
    <add>
      <b>Birth Year</b>
    </add>
    <add>
      <b>Current Year</b>
    </add>
    <add>
      <b>Birth Month</b>
    </add>
    <add>
      <b>Current Month</b>
    </add>
    <add>
      <b>Birth Day</b>
    </add>
    <add>
      <b>Current Day</b>
    </add>
    <add>
      <b>Expected Output (Age)</b>
    </add>
    <add>
            1990
         </add>
    <add>
            2010
         </add>
    <add>
            6
         </add>
    <add>
            6
         </add>
    <add>
            2
         </add>
    <add>
            3
         </add>
    <add>
            20
         </add>
    <add>
            1985
         </add>
    <add>
            2010
         </add>
    <add>
            5
         </add>
    <add>
            5
         </add>
    <add>
            3
         </add>
    <add>
            1
         </add>
    <add>
      <segment width="25" id="test7" height="1" />
    </add>
    <add>
      <segment width="25" id="test8a" height="1" />
    </add>
    <add>
      <segment width="25" id="test8b" height="1" />
    </add>
    <add>
      <segment width="25" id="test8c" height="1" />
    </add>
    <add>
      <segment width="25" id="test8d" height="1" />
    </add>
    <add>
      <segment width="25" id="test8e" height="1" />
    </add>
    <add>
      <segment width="25" id="test8f" height="1" />
    </add>
    <add>
      <segment width="25" id="test8g" height="1" />
    </add>
    <add>
      <segment width="25" id="test9a" height="1" />
    </add>
    <add>
      <segment width="25" id="test9b" height="1" />
    </add>
    <add>
      <segment width="25" id="test9c" height="1" />
    </add>
    <add>
      <segment width="25" id="test9d" height="1" />
    </add>
    <add>
      <segment width="25" id="test9e" height="1" />
    </add>
    <add>
      <segment width="25" id="test9f" height="1" />
    </add>
    <add>
      <segment width="25" id="test9g" height="1" />
    </add>
    <add>
      <segment width="25" id="test10a" height="1" />
    </add>
    <add>
      <segment width="25" id="test10b" height="1" />
    </add>
    <add>
      <segment width="25" id="test10c" height="1" />
    </add>
    <add>
      <segment width="25" id="test10d" height="1" />
    </add>
    <add>
      <segment width="25" id="test10e" height="1" />
    </add>
    <add>
      <segment width="25" id="test10f" height="1" />
    </add>
    <add>
      <segment width="25" id="test10g" height="1" />
    </add>
    <add>
      <segment width="25" id="test11a" height="1" />
    </add>
    <add>
      <segment width="25" id="test11b" height="1" />
    </add>
    <add>
      <segment width="25" id="test11c" height="1" />
    </add>
    <add>
      <segment width="25" id="test11d" height="1" />
    </add>
    <add>
      <segment width="25" id="test11e" height="1" />
    </add>
    <add>
      <segment width="25" id="test11f" height="1" />
    </add>
    <add>
      <segment width="25" id="test11g" height="1" />
    </add>
  </labtable><evaluator name="regex" labid="Facebook: Functions" href="evaluator://RegExEvaluator">
    <arg>
      <name>regex</name>
      <value>^\s*24\s*$</value>
    </arg>
    <arg>
      <name>failed-message</name>
      <value>I'm sorry, the expect output you entered for row 2 is incorrect.</value>
    </arg>
    <arg>
      <name>success-message</name>
      <value />
    </arg>
    <segid>
      <id>test7</id>
    </segid>
  </evaluator><hint /><evaluator name="C Evaluator" labid="Facebook: Functions" href="http://evaluators.web-ide.org/webide/evaluators/CEvaluator/CEvaluator.php">
    <arg>
      <name>functionCode</name>
      <value>int getAge(int birthYear, int curYear, int birthMonth,       int curMonth, int birthDay, int curDay)            {             int current = curYear*10000 + curMonth*100 + curDay;             int birth = birthYear*10000 + birthMonth*100 + birthDay;             return (current - birth)/10000;            }</value>
    </arg>
    <arg>
      <name>functionCall</name>
      <value>getAge(@test8a, @test8b, @test8c, @test8d, @test8e, @test8f)</value>
    </arg>
    <arg>
      <name>expectedOutput</name>
      <value>@test8g</value>
    </arg>
    <arg>
      <name>smessage</name>
      <value />
    </arg>
    <arg>
      <name>fmessage</name>
      <value>I'm sorry, the 3rd row of the table is incorrect.</value>
    </arg>
    <segid>
      <id>test8a</id>
    </segid>
    <segid>
      <id>test8b</id>
    </segid>
    <segid>
      <id>test8c</id>
    </segid>
    <segid>
      <id>test8d</id>
    </segid>
    <segid>
      <id>test8e</id>
    </segid>
    <segid>
      <id>test8f</id>
    </segid>
    <segid>
      <id>test8g</id>
    </segid>
  </evaluator><hint /><evaluator name="C Evaluator" labid="Facebook: Functions" href="http://evaluators.web-ide.org/webide/evaluators/CEvaluator/CEvaluator.php">
    <arg>
      <name>functionCode</name>
      <value>int getAge(int birthYear, int curYear, int birthMonth,       int curMonth, int birthDay, int curDay)            {             int current = curYear*10000 + curMonth*100 + curDay;             int birth = birthYear*10000 + birthMonth*100 + birthDay;             return (current - birth)/10000;            }</value>
    </arg>
    <arg>
      <name>functionCall</name>
      <value>getAge(@test9a, @test9b, @test9c, @test9d, @test9e, @test9f)</value>
    </arg>
    <arg>
      <name>expectedOutput</name>
      <value>@test9g</value>
    </arg>
    <arg>
      <name>smessage</name>
      <value />
    </arg>
    <arg>
      <name>fmessage</name>
      <value>I'm sorry, the 4th row of the table is incorrect.</value>
    </arg>
    <segid>
      <id>test9a</id>
    </segid>
    <segid>
      <id>test9b</id>
    </segid>
    <segid>
      <id>test9c</id>
    </segid>
    <segid>
      <id>test9d</id>
    </segid>
    <segid>
      <id>test9e</id>
    </segid>
    <segid>
      <id>test9f</id>
    </segid>
    <segid>
      <id>test9g</id>
    </segid>
  </evaluator><hint /><evaluator name="C Evaluator" labid="Facebook: Functions" href="http://evaluators.web-ide.org/webide/evaluators/CEvaluator/CEvaluator.php">
    <arg>
      <name>functionCode</name>
      <value>int getAge(int birthYear, int curYear, int birthMonth,       int curMonth, int birthDay, int curDay)            {             int current = curYear*10000 + curMonth*100 + curDay;             int birth = birthYear*10000 + birthMonth*100 + birthDay;             return (current - birth)/10000;            }</value>
    </arg>
    <arg>
      <name>functionCall</name>
      <value>getAge(@test10a, @test10b, @test10c, @test10d, @test10e, @test10f)</value>
    </arg>
    <arg>
      <name>expectedOutput</name>
      <value>@test10g</value>
    </arg>
    <arg>
      <name>smessage</name>
      <value />
    </arg>
    <arg>
      <name>fmessage</name>
      <value>I'm sorry, the 5th row of the table is incorrect.</value>
    </arg>
    <segid>
      <id>test10a</id>
    </segid>
    <segid>
      <id>test10b</id>
    </segid>
    <segid>
      <id>test10c</id>
    </segid>
    <segid>
      <id>test10d</id>
    </segid>
    <segid>
      <id>test10e</id>
    </segid>
    <segid>
      <id>test10f</id>
    </segid>
    <segid>
      <id>test10g</id>
    </segid>
  </evaluator><hint /><evaluator name="C Evaluator" labid="Facebook: Functions" href="http://evaluators.web-ide.org/webide/evaluators/CEvaluator/CEvaluator.php">
    <arg>
      <name>functionCode</name>
      <value>int getAge(int birthYear, int curYear, int birthMonth,       int curMonth, int birthDay, int curDay)            {             int current = curYear*10000 + curMonth*100 + curDay;             int birth = birthYear*10000 + birthMonth*100 + birthDay;             return (current - birth)/10000;            }</value>
    </arg>
    <arg>
      <name>functionCall</name>
      <value>getAge(@test11a, @test11b, @test11c, @test11d, @test11e, @test11f)</value>
    </arg>
    <arg>
      <name>expectedOutput</name>
      <value>@test11g</value>
    </arg>
    <arg>
      <name>smessage</name>
      <value>Good Job!</value>
    </arg>
    <arg>
      <name>fmessage</name>
      <value>I'm sorry, the 6th row of the table is incorrect.</value>
    </arg>
    <segid>
      <id>test11a</id>
    </segid>
    <segid>
      <id>test11b</id>
    </segid>
    <segid>
      <id>test11c</id>
    </segid>
    <segid>
      <id>test11d</id>
    </segid>
    <segid>
      <id>test11e</id>
    </segid>
    <segid>
      <id>test11f</id>
    </segid>
    <segid>
      <id>test11g</id>
    </segid>
  </evaluator><hint /></step>
  <step name="Exact Age Calculator" buttonName="Check"><dependency stepName="Exact Age Calculator- Tests" /> 
      Now write the function to calculate the exact age of a person when given their 
      birth year, month, and date, as well as the current year, month, and date. 

      <br />
      You can use this math trick to calculate age!<br />
      
      1. Convert inputed values into this format: YYYYMMDD<br />
      2. Subtract the birth information from the current information<br />
      3. The first <i>three digits</i> of your answer is the person's age. 
         (Note that in most cases the first digit will be zero)
      <dl>
    <dt>
      <b>Example:</b>
    </dt>
    <dd>Birth: 19900510</dd>
    <dd>Current: 20100803</dd>
    <dd>Current - Birth : 0200293</dd>
    <dd>First 3 Digits: 020</dd>
    <dd>This person is 20 years old.</dd>
  </dl><br />

      For the purposes of this exercise please name your function <i>ageCalculator</i> and 
      refer to your parameters as <i>birthYear</i>, <i>curYear</i>, <i>birthMonth</i>,  <i>curMonth</i>, 
      <i>birthDay</i>, <i>curDay</i> in that order.
      <segment width="700" id="ageCalculator" height="200" /><evaluator name="C Evaluator" labid="Facebook: Functions" href="http://evaluators.web-ide.org/webide/evaluators/CEvaluator/CEvaluator.php">
    <arg>
      <name>functionCode</name>
      <value>@ageCalculator</value>
    </arg>
    <arg>
      <name>functionCall</name>
      <value>ageCalculator(1980, 2010, 6, 6, 2, 1)</value>
    </arg>
    <arg>
      <name>expectedOutput</name>
      <value>29</value>
    </arg>
    <arg>
      <name>smessage</name>
      <value>Good Job!</value>
    </arg>
    <arg>
      <name>fmessage</name>
      <value>Your age calculator function compiles, but it does not work properly. Please review the specifications.</value>
    </arg>
    <segid>
      <id>ageCalculator</id>
    </segid>
  </evaluator><hint /></step>
  <step name="Employee Pay" buttonName="Run Tests!"><dependency stepName="Exact Age Calculator" /> 
     When you are done with this step, complete <a href="http://www.surveymonkey.com/s/P56G85M">this survey</a>.  
     You will be asked to 
     copy your program (function and tests) from this problem into the last question of the survey.<br /><br />
     Use the C programming area on the first page of <a href="http://web-ide.org">WebIDE</a> to 
     complete the following program.  Write a function and a set of tests to solve the following problem:<br /><br />
     Employees are paid time and a half for overtime.
     Overtime is any hours above 40 in a week.
     Write a function that accepts a total number of hours worked in a week (e.g. 45), 
     and an hourly pay rate (e.g. 11.50).  
     Your function should return the
     employee's total pay for the week, rounded down to the nearest dollar.
     You may assume that both parameters will be positive.<br /><br />
     Be sure that your tests thoroughly test your function.  <br /><br />
  </step>
  <step name="Congratulations!"><dependency stepName="Employee Pay" />
      Congratulations!  You made it to the end.  
    </step>
</lab>
