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.
- II B7-8: The student can develop and use abstractions.
- IV A15-B16: The student can develop and express an algorithm in Pseudocode and App Inventor.
- VB 20-22: The student can use abstractions (specifically functions) to manage complexity in programs and develop a
correct program (with functions).
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.
- 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.
- 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.
- (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.