Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
COMP101 - PRACTICAL SESSION 2 COMP101 PRACTICAL EXERCISE 2 - FLOATING BARGE (Week 5 Starting Monday October 23rd 2006) Hand in date - one week after your scheduled tutorial session in week 5. 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. COMPUTER SCIENCE DEPARTMENT HEALTH WARNING: NOT HANDING IN PRACTICALS CAN SERIOUSLY JEOPARDISE YOUR DEGREE! 1. REQUIREMENTS 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: Calculate the surface area of the barge using the identity: surfaceArea (m) = 2H(L+B)+LB Calculate the mass (weight) of the barge using the identity: massOfBarge (tonnes) = surfaceArea X 1.06 Calculate the draft using the identity (assuming water weighs 1 tonne per m3): 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: Refer to the Pythagoras and 2D geographic distance example problems presented in lectures to get a "feel" for the nature of the problem solution. Example test harness code can be found in the notes with respect to the Pythagoras, and 2-D geographic distance example problems. 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. 2. REPORT Your solution should comprise the following: Requirements: Summary of the above requirements statement. Analysis and Design: A short (one paragraph) description of your analysis of the problem including a Class Diagram outlining the class structure for your proposed solution, a complete set of "summary tables", and Nassi-Shneiderman chart for each. Note that your solution should comprise two classes: an "application class" and a "target class". Implementation: Your Java source files, i.e. the relevant .java files, not the class (.class) files. Testing: A set of proposed test cases presented in tabular format, and evidence of the results of testing (the simplest way of doing this is to cut and paste the result of running your test cases into your report). Declaration: A completed "Declaration on Plagiarism and Collusion". 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. 3. MARK SCHEME 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