1 / 12

ENGI 2420 Structured Programming (Lab Tutorial 3)

ENGI 2420 Structured Programming (Lab Tutorial 3). Memorial University of Newfoundland. 3.1 Problems in Assignment-2 3.2 Some Reminders 3.3 Assignment-3. Lab Tutorial 3. 3.1 Problems in Assignment-2. 3.1 Problems in Assignment-2.

ailis
Download Presentation

ENGI 2420 Structured Programming (Lab Tutorial 3)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ENGI 2420Structured Programming (Lab Tutorial 3) Memorial University of Newfoundland

  2. 3.1 Problems in Assignment-23.2 Some Reminders3.3 Assignment-3 Lab Tutorial 3

  3. 3.1 Problems in Assignment-2 3.1 Problems in Assignment-2 • It is your responsibility to ensure that your assignN.cpp can be correctly compiled with the other downloadable files (available in the assignment requirement on the web) in an Eclipse project • Functions in assign2.cpp should exactly follow the declaration given in assign2.h e.g., for “double rotationalVelocity (double inRotVel, double inTeeth, double outTeeth);”, you should NOT define in assign2.cpp: double rotationalVelocity(double inRotVel, int inTeeth, int outTeeth)

  4. 3.1 Problems in Assignment-2 Common Problems • Correctly understand the meaning of the parameters on the function argument list e.g., InTeeth => number of teeth on the gear that is being driven by the gear to its left OutTeeth => number of teeth on the gear that is driving the gear on its right  double g2RotVel = rotationalVelocity ( inRotVel, g1Teeth, g2OutTeeth );  double g2RotVel = rotationalVelocity(inRotVel, g1Teeth, g2InTeeth);

  5. 3.2 Some Reminders 3.2 Some Reminders • Due time: Wednesday (Feb. 6, 2008) at 11:59pm for all lab sections except 5 and 12 (Wednesday labs), Thursday (Feb. 7, 2008) at 11:59 for lab sections 5 and 12 • Lab Help Centre will be held at 17:00-18:00 on Tuesdays and Wednesdays in Lab 3000/3029

  6. 3.3 Assignment-3 3.3 Assignment-3 • Structure of C++ files - a3main.cpp: contains a code that calls the functions using input typed in by the user (Note that you are not expected to understand all of the code in this file at this point in the course) - assign3.h: contains the declarations for the functions - assign3.cpp: contains your implemented functions • Implement three functions as follows

  7. 3.3 Assignment-3 Function 1 • double deceleration ( double v0, double v1, double delta_t )- compute the rate of deceleration, in m/s2, of a body given two speed measurements (v0 and v1) in km/h and the time between the measurements (delta_t) in seconds. - hint: consider unit conversion

  8. 3.3 Assignment-3 Function 2 • double timeToStop( double v0, double delta_v, double delta_t ) - compute the time, in seconds, that a body will take to stop given it's initial speed, in km/h, (v0) and a change in speed in km/h (delta_v) and the time taken for that change in speed in seconds (delta_t) - this function must call deceleration function to compute the deceleration

  9. 3.3 Assignment-3 Function 3 • double distanceToStop( double v0, double delta_v, double delta_t ) - compute the distance, in metres, that a body will take to stop given it's initial speed, in km/h, (v0) and a change in speed in km/h (delta_v) and the time taken for that change in speed in seconds (delta_t) - this function must call deceleration to compute the deceleration, and timeToStop to compute the time

  10. 3.3 Assignment-3 Execution Example (I) Available options: 1 - Test deceleration 2 - Test timeToStop 3 - Test distanceToStop 0 - Quit Please enter a selection: 1 Enter the initial speed in km/h: 13 Enter the second speed in km/h: 10 Enter the seconds elapsed between the speeds: 60 deceleration(13, 10, 60) = 0.0138889

  11. 3.3 Assignment-3 Execution Example (II) Available options: 1 - Test deceleration 2 - Test timeToStop 3 - Test distanceToStop 0 - Quit Please enter a selection: 2 Enter the initial speed in km/h: 13 Enter the decrease in speed in km/h: -3 Enter the seconds elapsed between the speeds: 60 timeToStop(13, -3, 60) = 260

  12. 3.3 Assignment-3 Execution Example (III) Available options: 1 - Test deceleration 2 - Test timeToStop 3 - Test distanceToStop 0 - Quit Please enter a selection: 3 Enter the initial speed in km/h: 13 Enter the decrease in speed in km/h: -3 Enter the seconds elapsed between the speeds: 60 distanceToStop(13, -3, 60) = 469.444

More Related