Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "1 ENGI 2420 Structured Programming (Lab Tutorial 1) Memorial University of Newfoundland."— Presentation transcript:

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

2 ENGI 2420 – Structured Programming Lab Tutorial 1 2 1.1Problems in the Last Assignment 1.2 Input and Output 1.3Some Reminders 1.4Assignment-1 Lab Tutorial 1

3 ENGI 2420 – Structured Programming Lab Tutorial 1 3 1.1 Problems in the Last Assignment  Always submit the right file (assignN.cpp) to web- submit (e.g., assign0.cpp rather than assign0.h)  How to show file extension in Windows- Explorer: Tools->Folder Options- >View->Hide extensions for known file types 1.1 Problems in the Last Assignment

4 ENGI 2420 – Structured Programming Lab Tutorial 1 4 Program Testing  Behavior of the submitted assignment will be checked by an automated testing program (unknown to you)  Assignment will be tested using a standard set of test cases (unknown to you)  Exactly follow the assignment instruction regarding input and output (including the return value of functions)  Order of input parameters is significant - function(parameter1, parameter2) K function(parameter2, parameter1) 1.2 Input and Output

5 ENGI 2420 – Structured Programming Lab Tutorial 1 5 1.3 Some Reminders  Unless otherwise indicated, all assignments are due at 11:59 pm the day after the lab for your section  Late assignments will not be accepted except by special permission of the lecturer  Include comments in your program if you feel they are pertinent  Lab Help Centre will be held at 17:00-18:00 on Tuesdays and Wednesdays in Lab 3000/3029 1.3 Some Reminders

6 ENGI 2420 – Structured Programming Lab Tutorial 1 6 1.4 Assignment-1  Structure of C++ files - a1main.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) - assign1.h: contains the declarations for the functions - assign1.cpp: contains your implemented functions  Implement four functions as follows 1.4 Assignment-1

7 ENGI 2420 – Structured Programming Lab Tutorial 1 7 Function 1  double gravity(double mass, double distance) - compute the gravitational potential in mks (SI) units of a point at a distance (in kilometres) from a single planetary mass (in kilograms) - hint: take the standard two mass gravitational equation and remove one of the masses - check Gravitational Constant from web (eg, www.google.com or en.wikipedia.org/wiki) 1.4 Assignment-1

8 ENGI 2420 – Structured Programming Lab Tutorial 1 8 Functions 2 and 3  double average(double data1, double data2, double data3, double data4) - compute the average of four pieces of data  double lp100k(double mpg) - convert miles per gallon to litres per 100 km - check unit conversion constants from web (eg, www.google.com using some key words such as “unit conversion”) 1.4 Assignment-1

9 ENGI 2420 – Structured Programming Lab Tutorial 1 9 Function 4  double extraStJohns(int days) according to the most recent census data the St. John's Metropolitan area is home to about 181,113 people; in contrast world population increases by about 205,480 every day. Create a function that will return the (decimal) number of new cities as big as St. John's that would be needed to accommodate the extra population for a given a number of days 1.4 Assignment-1

10 ENGI 2420 – Structured Programming Lab Tutorial 1 10 Execution Example (I) Available options: 1 - Test gravity 2 - Test average 3 - Test lp100k 4 - Test extraStJohns 0 - Quit Please enter a selection: 1 Enter a planet mass (kg): 1000 Enter the distance of test point from the centre of the planet (km):10000 gravity( 1000, 10000) = 6.67428e-022 1.4 Assignment-1

11 ENGI 2420 – Structured Programming Lab Tutorial 1 11 Execution Example (II) Available options: 1 - Test gravity 2 - Test average 3 - Test lp100k 4 - Test extraStJohns 0 - Quit Please enter a selection: 2 Enter four numbers to average: 100 200 300 400.8 average(100, 200, 300, 400.8) = 250.2 1.4 Assignment-1

12 ENGI 2420 – Structured Programming Lab Tutorial 1 12 Execution Example (III) Available options: 1 - Test gravity 2 - Test average 3 - Test lp100k 4 - Test extraStJohns 0 - Quit Please enter a selection: 3 Enter fuel consuption in miles per US gallon: 20 lp100k( 20) = 11.7607 1.4 Assignment-1

13 ENGI 2420 – Structured Programming Lab Tutorial 1 13 Execution Example (IV) Available options: 1 - Test gravity 2 - Test average 3 - Test lp100k 4 - Test extraStJohns 0 - Quit Please enter a selection: 4 Enter a number of days (whole number): 10 extraStJohns( 10) = 11.3454 1.4 Assignment-1


Download ppt "1 ENGI 2420 Structured Programming (Lab Tutorial 1) Memorial University of Newfoundland."

Similar presentations


Ads by Google