EEEE1001: Computer Aided Engineering, University of Nottingham, UK
1. Overview of task
This task is designed to show you how to produce the material required for the successful development of a small piece of software (the coding of which may be done by a third party).
As such, instructions (both written and associated diagrams such as flowcharts) need to be unambiguous. In addition, sufficient test data must be supplied to allow the code to be tested at function level (the individual parts) and at system level.
When designing (and writing) code you should remember a few key points
The code should be written using ‘best practice' e.g.
o Remembering to use comments
o Good indenting
o Sensible variable/function names
Where input is required from the user you should validate this to ensure it is ‘fit for purpose' e.g.
o If the user is required to enter a length/resistance check it is ≥ zero
o If a range is specified, ensure the value entered is within this.
Error checking should be used e.g.
o If a file is required to be opened, was this successful? If not - what should be done?
o If memory is to be allocated dynamically, was this successful? - what happens if not?
2. The Task
Consider a projectile fired from a cannon with velocity Vo at the angle α as shown in figure 1.
Figure 1 – Projectile fired from a cannon
These values can be resolved into two separate velocities, one horizontal VX and one vertical VY , as given by:
VX = Vα cos(α)
VY = Vα sin(α)
It is then possible to calculate the horizontal and vertical components of the projectile at time t by using the following two equations:
x = vx .t
y = vyt + ½ at2
You may assume that a = -9.81ms-1 (The value is negative as we are opposing gravity).
2.1 Requirements (to be reflected in your flowchart & other material)
Documentation (primarily a flowchart & test data) are to be created to ensure the following tasks are performed. Note that in some cases you will need to specify the exact message to be displayed (e.g. for an invalid input) which should then be validated through test cases.
(a) The application should prompt the user to enter the firing angle and velocity of the projectile.
NOTE: Suitable error checking should be included to ensure that the values entered are appropriate to the task.
Where they are not, the user should be informed of the correct range(s) and the application is to terminate.
(b) Functions (external to main() ) are to be used to resolve the firing angle into the horizontal and vertical components. These values are to be displayed on the screen at a suitable precision.
(c) Design a suitable function (external to main() ) that determines the time of flight (TOF) after which the projectile will return to ground level (i.e. when y=0). Display this value on the screen at a suitable precision.
(d) Display the horizontal and vertical distances of the projectile for the duration of the flight (i.e. t=0 to t=TOF) at 10 equally spaced intervals (which include t=0 & t=TOF).
You may wish to use sub processes (mini flowcharts) for the functions - these indeed would be ideal as part of a larger project as then individual developers/programmes could work on these - bringing the parts together to form the finished application.
2.2 Development of code
For this exercise you DO NOT need to submit your code (this exercise focuses on the design of code).