During the first hour of the lab class you will complete the MidTerm exam (see Notices). This document covers the practical work for the second hour.
After completing this lab, students should be able to
As with most labs, one mark is awarded to successful attempts at an online exercise. The exercise will require you to enter a series of assignment statements, which you will need to embed in a subprogram, similar to the main exercise.
For the other two marks your tutor will ask you to demonstrate your program. As with all labs in this course, you may be asked to explain your solution and how you devised it. Your tutor will record whether you have successfully completed the work, provided he or she is confident you fully understand the solution and it is reasonably well presented.
To help you adopt good habits you submit your completed or indevelopment lab
and assignment work to our Style Assessor.
It will carefully scrutinise things like indenting, indentifier naming,
author/date comments
and for this lab especially, using suitablynamed constants instead of literal numbers
(apart from obvious ones like 0, 1 or 2).

Imagine a rope circling the Earth at the equator, tight against the surface (assume the earth is a spheroid and the equator is circular). If you were to cut the rope, insert a one metre long section, and move the rope uniformly away from the surface, how far away would the rope be from the Earth now? (Most people guess a fraction of a millimetre.) 
You can solve this with simple geometry, since circumference and radius of a circle are related by the obvious formula C = 2πR where R is the radius and C is the circumference. And yes, there is an obvious analytical solution to the problem, but we're just using it as an example of a sequential (stepbystep) algorithm.
Download the workbook lab05.ods to the Desktop. Later save it to a USB drive if you have brought one, or your Z: drive, which is preserved. Of course you may have done the exercise at home. The workbook contains very little content, you could well have started with a new workbook.
Navigate to Tools  Macros  Organize Macros  OpenOffice Basic... then press Organizer. Click on the + next to lab05.ods, and then the Standard icon (if there is one).
Press New. Call the module RopeParadox. Press Edit to open the editor.
The subprogram to solve the problem will use the structure
from the lecture example.
Start with a comment describing the problem,
and your name as author, plus today's date.
Then we need two important constants, one defining the value of π and one the radius of the Earth at the equator, which is 6378.137 kilometres using the GPS world model. By convention their names are written in upper case:
Option Explicit ' require all variables to be declared ' Calculates how far out from the equator's surface ' a rope 1m longer than the equatorial circumference would lie. ' Author: ______________________ ' Written: __/__/__ Const PI = 3.14159265358979 Const EQUATOR_RADIUS = 6378.137 ' semimajor axis of the WGS 84 Ellipsoid, in km ' Ref: National Geospatial Intelligence Agency, ' http://earthinfo.nga.mil/GandG/wgs84/gravitymod/egm96/egm96.html
Next, define a constant for the conversion factor (say KILO) between km and m.
Following the constants change the default subprogram name from Main to ShowRopeParadox.
Within the subprogram, indented, you will need to declare variables to hold the various calculated circumferences and radii. You need one for each of: the extra length, earth's circumference, the rope circumference after the extra length is inserted, the new rope radius, and the difference in radii, which is the answer we want.
The variable names should be two or threeword phrases in TitleCaseRunTogether, but with an initial small letter so it's clearly a variable name. You can abbreviate if it's obvious. For example,
Dim ropeCircum As Double ' circumference of rope after adding the extra bit
The extra rope length (1m in the original puzzle) should be obtained from the user with the InputBox function, similar to the lecture example, but assigned to the first of your appropriately named variables.
Now use assignment statements to calculate values for each of the other variables in turn. Think about how you'd do the calculations on paper, one step at a time (don't try to solve the whole thing at once). In all forms of Basic, the notation is
variable = expressionwhere variable is the name of the variable to be assigned to, and expression comprises variables, literal numbers and named constants, combined with the usual arithmetic operators (but which is the appropriate division operator?). Remember that the equatorial radius is in kilometres but the extra length is in metres (1.0 to be exact). The answer should also be in metres, so you'll have to apply an appropriate factor.
Having worked out the difference in radii, use MsgBox to show its value on a popup window, along with a brief message. Glue the parts of the message together with the & operator. Again it's like the lecture example: what you're doing is adopting a solution pattern and adapting it to suit your particular needs, a common approach.
You can run the subprogram one of two ways: the quickest is to press F5 or the little blue triangle, but you should also try the sheet menu Tools  Macros  Run Macro.
We won't give the answer away, but if the number your program produces is negative, or really tiny (say 1e9 metres) or really huge (say several kilometres) it's probably wrong. Recheck the statements carefully, especially the conversion between km and m.
To show why it's a paradox, now change the constant holding the equatorial radius to 0.55, which is the approximate radius in km of the roughly circular cycling track around Centennial Park. Note how you only had to change the constant value at one place, even though you probably used it twice.
Show your program to the tutor, and explain the results. If you want full marks from them, your style mark should be 4/4 and you will have to investigate how to use the Format function to express the answer to 3 decimal places (Hint: a suitable format code is "0.000"). This produces a much more satisfying result, and is described in the OO Basic Help.