Assignment Set Eight

Conventional grading students should complete Items C and G for another grade. Item G is the last paper assignment for the class.

The following are for the contract grading students

Those students completing Item A or Item B by the special deadline announced in Sneak Preview One earn an A on this assignment.

C - "on time" one program from Item A to Item C, plus 9 other activities

B - "on time" one program from Item D to Item E, plus 9 other activities.

A - "on time" one program from Item D to Item E, plus 9 other activities.
(It may turn out there might be no "slightly late" date as the end of the semester might hit before that occurs. Thus the activities for this assignment set must be either on time or slightly late, or they simply will not be accepted.)

Bonus:

This problem will be given out at a SNEAK PREVIEW earlier in the semester. If you complete this first problem by SNEAK PREVIEW deadline, you will receive the grade of A on this homework. If you later earn the requirements stated above to earn a B, your final grade on this homework assignment set, will be A+. If you later meat the requirements to an A as stated above, your final grade on this will be an A++.

For those students doing work on this assignment at the end of the semester, you will receive four activity points for ON TIME completion of this assignmetn set.

Item A.

Write a procedure called SumThree.

It takes four arguments. The first three are input; the last argument is an output argument.

The procedure SumThree will add the three input arguments and put the result into the last argument.

You should have four calls to the procedure SumThree. Of course, these should all appear in your main program.

In the first call to SumThree, the variable DingBat should be set to the sum of the variables Tin, Copper, and Silver.

In the second call to sumthree, the variable Stupid should be set to the sum of the variables Gold, Iron, and Lead.

In the third call to SumThree the variable Idiot should be set to the sum of the variables: Uranium, Titanium, and Zirconium.

After these computations, the fourth call of SumThree should set the variable SumAll to the sum of DingBat, Stupid, and Idiot.

Your main program should read from the keyboard, the variables: Tin, Copper, Silver, Gold, Iron, Lead, Uranium, Titanium, and Zirconium.

After performing the four calls to SumThree, your program should write out the variables DingBat, Stupid, Idiot, and SumAll.

Item B.

Write a procedure called MinMax.

It takes four arguments. The first two are for input and the second two are for output.

They are:

1.    An input variable, Input1

2.    An input variable, Input2

3.    An output variable, Min

4.    Another output variable, Max 
The MinMax procedure should put the minimum of the first two arguments, Input1 and Input2, into Min and the maximum of the two input arguments into Max.

You should have six calls to the procedure MinProd. Of course, these all appear in your main program.

You will need eleven global variables, Extra, B, L, M, P, Q, R, S, T, V, and W. In the first call to MinMax, V should be set to the minimum of Q and R as well as setting W to the maximum of Q and R.

In the second call, S should be set to the minimum of L and M as well as setting T to the maximum of L and M.

In the third call to MinMax, P should be set to the minimum of V and S.

In the fourth call to MinMax, B should be set to the maximum of W and T.

In the fifth call to MinMax, GrandMax should be set to the maximum of B and Extra.

In the sixth call to MinMax, GrandMin should be set to the minimum of P and Extra.

Your main program should read from the keyboard Q, R, L, M, and Extra. It should also print out V, W, S, T, P, B, GrandMax, and GrandMin.

Item C.

Write a procedure called Power. It should take three arguments. The first two will represent a number and integer power. The third will be the result.

It should compute the first number raised to the second argument as a power. Result of this shall be put in the third argument.

For example,

A := 2;
B := 4;
Power (A, B, C)

would put 24 into C.

Now use your Power function to compute the "left-associative zigamorph" and the "right-associative zigamorph." The zigamorph function is to powers what powers are to multiplication.

However, with zigamorph's, it matters whether we group the numbers from right to left or from left to right.

'2 zigamorph 4' would correspond to one of the following two quantities.
(( 2 SUP 2 ) SUP{ 2} ) SUP 2) = 256

(1) Left Associative Zigamorph

The left associative zigamorph would equal the number 256.
(2 SUP{ (2 SUP{ (2 SUP 2)})}) = 65,536
(2) Right Associative zigamorph

The right associative zigamorph would equal the number 65,536.

Your program should read in two quantities. Call them A and B. Then compute A zigamorph B by left-associative zigamorph and A zigamorph B by right-associative zigamorph. Print out results.

Use the Power routine you wrote earlier.

Item D.

Take any program you wrote for assignment set 6 or 7, and convert the program so the essential algorithium is in a procedure or function. Your main program should do nothing more than read in the arrays or values and invoke the procedure you just wrote.

For example, if you were converting the program to sort an array , you would write a routine that would take two arguments

1) the array to be sorted
2) the number of values actually in the array.

It would then change sort the array in argument 1.

The logic to read in the data to be sorted and print out the result would be left in the main program.

Item E.

(This counts as two activities)

Read up on passing "procedural variables" to procedures in the Turbo Pascal 6.0 Programmer's Guide (page 111 and 112).

Convert the sorting program from Unit 5.6 into a procedure that it takes two procedures as parameters.

The first procedure will be a function that when given two integers, I and J, will determine if record I is greater than record J. If it is, the function should return 1, otherwise it should return 0.

The other procedure will again take two integers I and J. It will swap element I with element J.

It will now sort the elements, calling the two procedures as appropriate. By changing the procedures passed, you can use the sort procedure for anything from sorting a simple array of integers to sorting the rows of a 2-D array.

You should show two programs using this routine. One might be a recoded version of Unit 5.5 and the other would probably be the sorting exercise you did for Assignment Set 6.

Item F.

What does the program below do? Be sure to show work. I will not be able to accept a submission without work that shows me you thought about what the program does, as opposed to simply typing it into the computer and running it.


Item G.

What does the program below do? Be sure to show work. I will not be able to accept a submission without work that shows me you thought about what the program does, as opposed to simply typing it into the computer and running it.

Item H. Counts as TWO activities

What does the program below do? Be sure to show work. I will not be able to accept a submission without work that shows me you thought about what the program does, as opposed to simply typing it into the computer and running it.

Note in some cases, the program will use an undefined value. Clearly indicate when this occurs in your answer.

Some Additional Writing Problems

Item I.

Read the Documentation Guidelines handed out with this assignment set.

Make Item C, if you did it, conform to these requirements.

Item J.

After reviewing the Documentation Guidelines handed out with this assignment.

Write up your own set of guidelines. Obviously, it shouldn't follow apishly the above mentioned guidelines but may use items in there as an inspiration.