ICS 3M Subroutine Assignment

Marks: 30

In this assignment you will be developing a number of functions and procedures. Save all of your work in a file called subs.t and print this out. Marks will be deducted for poor comments, and poor style.

1. Design a function called InToCm that takes a value in inches and returns the equivalent in centimeters. (4 marks)

2. Design a procedure called drawcross that draws a cross on the screen. The parameters will operate in the same fashion as drawstar, except do not allow for inverted crosses. (5 marks)

3. Design a function called invest that will calculate the amount of money you will have if you invest your money over a period of years compounding the money yearly. The procedure will have 3 parameters.

1. Amount of money invested

2. Number of years.

3. Interest rate.

The function will return the total money after the time is up. (5 marks)

4. Design a procedure called order that takes three integer variables and switches their values so that the first paramer holds the smallest value, the second hols the 2nd largest and the third holds the largest.

5. Design a procedure that draws a grid on the screen. This must be done recursively. You will have a procedure that draws a box, and inside the box draws four grids. ( 5 marks )

6. Multiplying the digits of an integer and continuing the process gives the surprising result that the sequence of products always arrives at a single-digit number. For example:

77 ®49 ® 36 ®18 ®8

88 ® 64 ® 24 ® 8

27 ® 14 ® 4

7. Design a menu that will call any of the above subroutines and gives the user a chance to specify values for the parameters. ( 5 marks )