Session 43

Activity #12



The Assignment

On Monday we worked together to crack the code for the Study Guide. Today I want you to work with a partner to practice some of the activities from that study guide to help you prepare for the final exam.


In a file called

  1. Write a function called totalCost(cost,taxrate,shipping) which takes in three numbers representing the cost of the item, the sales taxrate and the cost of shipping (for example, totalCost(19.99,7,3.25) and returns the total cost of that item in my example, 24.64 (24.6393 without any rounding)
  2. Write a function called countLetters(string,letter) that returns how many of one certain letter there are in a particular string. countLetters(“banana”,”a”) returns 3. countLetters(“banana”,”u”) returns 0.
  3. Pick one other function from the list of sample functions in the study guide and complete that OR Revisit the totalCost function and get it to only return the actual dollars and cents (return 24.64 rather than 24.9393 using the numbers in my example.)


Submitting your assignment

Once you have everything completed and working it is time to prepare your assignment for submission. Submit

using the homework submission system.

Make sure you include a proper header in your code which includes the name of BOTH partners.