COS1511/102/3/2011
Introduction to programming 1 Tutorial letter 102 for COS1511 Solutions to exercises in the Study Guide
School of Computing
2 TUTORIAL MATTER
Up to now you should have received the material listed below. If not, please download it from myUnisa or osprey immediately (see below) and also contact the Department of Despatch. Study Guide DISK 2011 (with software ) Tutorial letters COSALLF/301/4/2011 General information concerning the School and study at Unisa COS1511/101/3/2011 Information about COS1511 Assignments COS1511/102/3/2011 This letter Please note the following • • For e-mail, use the module address namely cos1511@osprey.unisa.ac.za. Web addresses for downloading of tutorial matter myUnisa.ac.za osprey.unisa.ac.za (logon: MYDOWNLOAD, password SOC2011) You need AT LEAST 8 hours study time per week for this module.
•
Afrikaanssprekende studente: Studiemateriaal vir COS1511 is vanaf 2011 slegs in Engels beskikbaar. As enigiets onduidelik is, is u baie welkom om ons te kontak.
Your programs need not be identical to ours. It is, however, important that your programs yield the correct results (thus extensive testing is essential) and that you use good programming style as explained in the Study Guide. You should, for example,
3
• • • • • • • use meaningful names for variables, constants, functions, etc, indent your code correctly, include comments, declare constants where appropriate, avoid the use of global variables, use the correct types of functions as well as the correct types of parameters.
COS1511/102/3/2011
LESSON 1 Lesson 1, Exercise 1 We repeat the program here: #include using namespace std; int main( ) { cout deepDep; cout > shallowDep; SwimmingPool pool(len, wid, deepDep, shallowDep); // round up to get an integer value for volume
82
vol = pool.volume( );