Programming Environment 2000 (Partial)

Question 1

 

The following Visual Basic program is designed to calculate and print the annual interest and balance for an investment account that:

·        has a fixed deposit amount of $100 invested at the beginning of each year

·        interest, at 10% of the balance, is calculated and paid into the account at the end of each year.

·        If the annual interest is greater than $20 then only half of the interest is reinvested back into the account.

The numbers in the left column are not part of the program, they are included for reference in your answers.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

Sub Investment()

Dim iYear As Integer, cBal As Currency, cYearInt As Currency

    cBal = 0

    iYear = 0

    While iYear <= 2

        iYear = iYear + 1

        cYearInt = cBal * 10 / 100

        If cYearInt > 20 Then

              cYearInt = cYearInt / 2

        End If

        cBal = cBal + 100 + cYearInt

        Debug.Print iYear, cYearInt, Format$(cBal, "$#,##0.00")

    Wend

End Sub

 

(a)        Construct a data dictionary for the subroutine Investment.

 

(b)        Construct a desk-top-check table made up of a column for each variable and using a line for each step of execution to show the order the statements are executed, the values of the variables at each step, plus any output produced.

 

(c)        The program contains a logical error.  What is it? What features of Microsoft Access would help in tracking down the error?

 
(d)        The program as given is restricted to a $100 investment amount over 2 years at 10% annual interest. Rewrite the program so that:

·        The values for these three figures can be entered by the user.

·        The logic error specified in (c) above is rectified.

·        Appropriate headings are printed.

 

(e)        Instead of calculating the interest at a straight 10% of the balance a bank uses the following sliding scale to calculate the interest:

·        First $1000 of the balance earns 8% interest

·        For the balance component between $1,000 and $5,000 the interest rate = 10%
eg. For balance of $3,000 the interest = $1,000 @ 8% plus $2,000 @ 10%

·        for the balance component over $5,000 the interest rate = 11%
eg. For a balance of $8,000 the interest = $1,000 @ 8% plus $4,000 @ 10% plus $3,000 @ 11%

Write the subroutine calcInterest in ONE OF pseudocode, Visual Basic or Java that determines the interest based on the balance. (Hard code the above cut-off balances and interest rates.)

 (2+4+3+5+6 = 20 marks) (36 minutes)

 


Question 3

 

The following files all exist on an Unix computer:

/usr/staff/john/.login

/usr/staff/john/bj.java

/usr/staff/john/public_html/index.html

/usr/pub/hangman

/usr/pub/gocats.gif

/usr/pub/geelong.gif

/etc/passwd

 

(a)        Draw a tree diagram showing all of these directories and files

(b)        Specify the home directory for staff member with account john

 

Assuming john has just logged on, give the Unix commands he would enter to perform the following in sequence:

(c)                Copy the computer game called ‘hangman’ file into his home directory

(d)               Play a game of hangman

(e)                View the contents of the file .login

(f)                 Print the file .login file (to any printer)

(g)                Edit his bj.java file

(h)                Compile the edited bj.java file

(i)                  Change the permissions of the bj.java file so nobody can alter (write to) it.

(j)                 Create the subdirectory pictures attached to his public_html directory

(k)               List all the files in the /usr/pub directory showing their permissions and size

(l)                  Copy all files ending with ‘.gif’ from the /usr/pub directory into the new pictures directory

(m)              Delete all files with extension ‘.java’ in his public_html directory

 

 (2+1+2+2+2+2+2+2+2+2+2+2+2 = 25 marks) (45 minutes)