|
Aims and Objectives: Provide an opportunity for students to design, implement and test a simple Java program that performs some straight forward arithmetic and makes use of one or more constants.
|
---|
Figure 1 shows an open topped iron barge of length L, Breadth B and Height H. Knowing that the iron from which the barge is built weighs about 1.06 tonnes per m2, we can calculate the draft d of the barge (the proportion of H which is submerged) using Archimedes' Principle:
When a body is immersed in a liquid it displaces a volume of liquid equivalent to the mass of the body.
(1 m3 of fresh water weighs 1 tonne). The calculation comprises three steps:
surfaceArea (m |
massOfBarge (tonnes) = surfaceArea X 1.06 |
draft (m) = massOfBarge/(LXB) |
EXAMPLE:
L=16 B=6 H=5 surfaceArea = (2x5)(16+6)+(16*6) = 10(22)+96 = 220+96 = 316 massOfBarge = 316*1.06 = 334.96 draft = 334.96/(16*6) = 3.49m
Of course if the required draft exceeds the height of the barge the barge will sink but ignore this minor inconvenience.
You should develop and implement a Java program which, given a barge defined in terms of inputs for L, B and H, outputs the associated draft.
Figure 1: Geometry of an open topped floating barge
TESTING Given that the problem has 3 inputs which can be either, 0 or a positive or negative number; arithmetic testing dictates that we require 33 (27) separate tests! Do not waste your time processing 27 separate test cases, instead write an additional application program --- a test harness --- to test your program (there is no need to hand in any design documentation for the test harness).
HINTS:
Remember that guidance notes on (1) the execution of COMP101 practicals, and (2) the presentation of work are available.
N.B. Should you, in any of the practicals, wish to make use of classes that have been presented in lectures or that are contained in the notes to date there is no need to provide design, implementation or testing details of those classes --- although you should note in your write up the fact that you are using additional classes that are not part of the Java API and not of your own design.
Your solution should comprise the following:
As with the previous exercise all supporting documentation (i.e. excluding source files) should be prepared as a single Microsoft Word file. Word includes a simple drawing capability which suffices when creating Class Diagrams and Nassi-Shneiderman charts. Remember, the easiest way of including "evidence of testing" is to simply cut and paste it into your word document.
Once completed you should "up load": (i) your Java source files (extension .java), (ii) your report (word document) and (iii) a comleted "Declaration on Plagiarism and Collusion", to the CS department's electronic practical assignment submission system.
90% of the marks will be distributed evenly between: Analysis and Design; Implementation; and Testing. The remaining 10% will be awarded for "overall presentation" (marks will be deducted if there is no "Declaration on Plagiarism and Collusion").
Guidance notes for the execution of COMP101 practicals are available. See also notes on practicals and course work for general guidance on the presentation of work, the COMP101 marking scheme and late submission policy.
Created and maintained by Frans Coenen. Last updated 30 October 2006