CPSC 110-08: Computing with Mobile Phones

Homework 7: Writing Functions
Due: Friday 10/14 (before class)

CS Principles

This reading and homework activity focuses on abstraction again, this time focusing on functions and parameters. The student will be introduced to functions as re-usable programming abstractions and will see how parameterization can be used to generalize a specific solution. It begins to address the following learning objectives.

Writing Functions in Pseudocode

Complete the following exercises, which were given at the end of the Functions Tutorial:

Write Pseudocode functions to perform the following calculations. Post your solutions on your Portfolio.

  1. Write a function named kmToMiles to convert from kilometers to miles using the formula: M = K × 0.62. This function should take 1 parameter, K, which represents the number of kilometers.

  2. Write a function named fahrToCelsius to convert from temperature in fahrenheit to temperature in celsius using the formula: C = 5⁄9(F-32). This function should take 1 parameter, F, that represents the temperature in Fahrenheit.

  3. (Optional) Write and test the functions in App Inventor and post a screen shot of your blocks on your Portfolio.

Getting Help

The TA is available to help you on this assignment between 9-10 PM on Tuesday and Thursday evenings in MCEC 136.