You are on page 1of 59

COS1511/101/3/2021

Tutorial Letter 101/3/2021

Introduction to Programming I
COS1511

Year 2021

School of Computing

This tutorial letter contains important information about your module.

BARCODE
CONTENTS
Page

1 INTRODUCTION TO THE MODULE..........................................................................................4

2 PURPOSE AND OUTCOMES.....................................................................................................5

2.1 Purpose ......................................................................................................................................5

2.2 Outcomes ...................................................................................................................................5

3 LECTURER(S) AND CONTACT DETAILS..................................................................................7

3.1 Lecturer(s) ..................................................................................................................................7

3.2 Department .................................................................................................................................7

3.3 University ...................................................................................................................................7

4 RESOURCES ..............................................................................................................................8

4.1 Joining myUnisa ........................................................................................................................8

4.2 Recommended book(s) ..............................................................................................................8

4.3 Electronic reserves (e-reserves)................................................................................................8

4.4 Library services and resources information..................................................................................9

5 STUDENT SUPPORT SERVICES ..............................................................................................9

5.1 E-Tutors.............................................................................................................................................10

5.2 Free computer and internet access ...............................................................................................10

5.3 Downloading study material and software.....................................................................................10

5.4 Announcements on myUnisa...........................................................................................................11

5.5 Installation of the software...............................................................................................................11

6 STUDY PLAN...............................................................................................................................12

7 PRACTICAL WORK.....................................................................................................................13

8 ASSESSMENT .............................................................................................................................13

8.1 Assessment criteria ....................................................................................................................13

8.2 Assessment plan .........................................................................................................................14

8.3 Assignment numbers ..................................................................................................................15

2 2
8.3.1 General assignment numbers......................................................................................................15

8.3.2 Unique assignment numbers ......................................................................................................15

8.4 Assignment due dates .................................................................................................................. 17

8.5 Submission of assignments .........................................................................................................18

8.6 Assignment 1 .………….................................................................................................................18


8.7 Assignment 2 .………………………………………..……………………………………………………23
8.8 Assignment 3 .……………………………………………………………………………………………..41
8.9 Assignment 4 .……………………….…………………………………….………………………………52

9 EXAMINATION………………………………………………………………………………………….…..59

10 FREQUENTLY ASKED QUESTIONS.............................................................................................59


11 SOURCES CONSULTED…………………………………………………………………………………59
12 IN CLOSING…………………………………………………………………………………..……………59

3 3
Dear Student

As part of this tutorial letter, we wish to inform you that Unisa has implemented a transformation
charter based on five pillars and eight dimensions. In response to this charter, we have
also placed curriculum transformation high on the agenda. For your information,
curriculum transformation includes the following pillars: student-centred scholarship, the
pedagogical renewal of teaching and assessment practices, the scholarship of teaching and
learning, and the infusion of African epistemologies and philosophies. These pillars and their
principles will be integrated at both the programme and module levels, as a phased-in approach.
You will notice the implementation thereof in your modules, and we encourage you to fully
embrace these changes during your studies at Unisa.

1 INTRODUCTION TO THE MODULE


Dear Student
Welcome to COS1511, Introduction to Programming.
We hope that you will find it interesting and stimulating. There are a number of first-year
Computer Science and Information Systems modules at Unisa. Here are some of the modules.

COS1511 deals with the basic concepts of programming and the design of algorithms,
using the programming language C++.

COS1511 is a further introductory course in C++ programming where object-


oriented programming is introduced. COS1511 is a pre-requisite for COS1512.

COS1521 provides a general background to computer systems.

INF1511 is an introduction to visual programming, and

COS1501 introduces the mathematics relevant to Computer Science.

Depending on your degree stream the advanced modules may or may not apply to you.
All the above modules are semester modules and you will need at least 8 hours per week for each,
especially for the programming modules. Programming is extremely time-consuming and we
do not recommend that you enroll for more than one programming module
simultaneously.
Because this is a blended module, you will need to use myUnisa to study and complete
the learning activities for this module. Visit the website for COS1511 on myUnisa frequently. The
website for your module is COS1511-20-Y1.
1.1 Getting started …

4 4
Owing to the nature of this module, you can read about the module and find your study material
online. Go to the website at https://my.unisa.ac.za and log in using your student number
and password. You will see COS1511-20-Y1 in the row of modules displayed in the orange
blocks at the top of the webpage. Select the More Sites tab if you cannot find the module
you require in the blocks displayed. Then click on the module you want to open.
We wish you much success in your studies!

2 PURPOSE AND OUTCOMES


2.1 Purpose
The purpose of the module is to introduce students to programming and to cover the
fundamentals of:

data and control structures;

techniques for problem solving and algorithm design;

input and output of data from and to the standard input/output streams;

data types and structures (i.e. floating point, integer, character, string, boolean, one
and two-dimensional arrays;

C++ decision and iteration structures, (i.e. if, while, for, switch and
do..while.);

functions with both reference and value parameters, as well as structs.

2.2 Outcomes
For this module, you will have to master the following outcomes:

Specific outcome 1:

You should be able to design a logical solution to a simple programming problem,


making appropriate assumptions.

Assessment criteria:
Through assignments and an examination at the end of the semester, you are assessed on your
ability to interpret a problem description that specifies the requirements of a program; as well as
identify all steps necessary to solve a problem and order the steps in the correct logical
sequence.

Specific outcome 2:

You should be able to write programs in C++, demonstrating the principles of good programming
practices.

5 5
Assessment criteria:

In the form of exercises in your study guide, written assignments (including working computer
programs) and examinations, you are assessed on your ability to:
Write functions and use them in a program; Use control structures to implement a
solution to a programming problem;
Define and use data types and data structures to implement the solution to
a programming problem;
Recognize / locate errors in the code and correct them;
Provide code for a small to medium sized working program (not exceeding 200 lines of
code).

Specific outcome 3:

You should be able to demonstrate an understanding of the theory underlying the basic
programming concepts.

Assessment criteria:
In the form of exercises in your study guide, written assignments (including working computer
programs) and examinations, you are assessed on your ability to:
Apply good programming principles;
Use the different programming constructs appropriately and correctly, in order
to implement a solution to a programming problem;
Apply the concepts of C++ required for beginner level computer programming.

Specific outcome 4:

You should be able to successfully locate errors in a fragment of code; demonstrating


an understanding of the syntax of the underlying programming language.

Assessment criteria:
In the form of tasks in the study material, written assignments (including computer programs)
and examinations, you will be assessed on your ability to
locate syntactic and logical errors in a given beginner level computer program;
locate syntactic and logical errors in your own written computer programs, in order
to implement a correct solution to a programming problem.
Specific outcome 5:

You can successfully construct a correct programming solution to a given problem,


demonstrating understanding of the stated problem and implementing the solution in
a structured format.

Assessment criteria:
In the form of tasks in study material, written assignments (including computer programs) and
examinations, you will be assessed on your ability to
analyse the problem and identify the necessary steps in order to produce the solution;

6 6
design a structured solution to the problem, making your own decisions of which
programming constructs should be used to reach the solution;
apply the different programming constructs appropriately and correctly to
successfully implement a programming solution to the problem.

Specific outcome 6:

You can demonstrate logical reasoning and analytical skills through the correct use of supplied
computer software to produce the solution to a stated problem.

Assessment criteria:
In the form of tasks in study material, written assignments (including computer programs) and
examinations, you will be assessed on your ability to
install the supplied compiler for the procedural programming language;
write, compile and run computer programs using the supplied software;
supply solutions to written and compiled programs after successfully running programs.

3 LECTURER(S) AND CONTACT DETAILS


3.1 Lecturer(s)
The names and contact details of your COS1511 lecturers are supplied in Tutorial Letter
SOCALL0/301/4/2020. The contact numbers of the lecturers for COS1511 are also available on
the module website for COS1511. In the meantime, If you have any academic query about the
module and would like to speak to a lecturer, you may do so in one of the following ways:

Send an email to the COS1511 email address by selecting the option COURSE
CONTACT on myUnisa.
For queries regarding the installation of the software, first see the FAQs and Additional
Resources for possible solutions. If there is no answer to your problem, contact the e-
tutor allocated to you or one of the lecturers.
Please note that for general (non-academic) queries, you will find contact details in the
brochure Study @ Unisa that you received with your study material.
Always have your student number ready when contacting the university.

3.2 Department
The School of Computing can be contacted telephonically at 011 670 9200 or via e-mail with the
e-mail address computing@unisa.ac.za. Should you be unable to reach any of the lecturers for
COS1511, please leave a message with one of the secretaries, who can be contacted via the
number given above. Remember to include the module code and your student number with the
message.

Telephone number: 011 670 9200

3.3 University

7 7
To contact the University, follow the instructions in the brochure Study @ Unisa. Remember to
have your student number available whenever you contact the University.
Whenever you contact a lecturer, please include your student number to enable the lecturer to
help you more effectively.

4 RESOURCES
4.1 Joining myUnisa
The myUnisa learning management system is the University's online campus which will help you
to communicate with your lecturers, with other students and with the administrative departments
at Unisa.

To go to the myUnisa website directly, go to https://my.unisa.ac.za. Click on the Claim UNISA


Login on the top of the screen on the myUnisa website. You will then be prompted to give your
student number in order to claim your initial myUnisa details, as well as your myLife email login
details.

For more information on myUnisa, consult the brochure Study @ Unisa, which you received
with your study material: www.unisa.ac.za/brochures/studies

Prescribed software
The software for this module is open-source. In other words, you are free to download, install, copy
and distribute it under the relevant open-source license. Open-source software for modules in the
School of Computing is available for download from the school's Osprey server:
http://osprey.unisa.ac.za/. From the home page, click on the SoC Registered Students link.
Then, if you haven't done so already, select your modules and click on the Submit button. You
should then see a link to the Open-source software repository under Resources.
The prescribed software for this module is Code::Blocks 16.01. We will refer to the software as
Code::Blocks. Code::Blocks includes the MinGW C++ compiler and an Integrated Development
Environment (IDE), which we use to create program files.

4.2 Recommended book(s)


You do not have to consult any textbooks. However, those of you who want to read further may
consider any of the books listed below. (They are not necessarily available in the Unisa library.)

HM Deitel and PJ Deitel. C++ How to Program, 6th edition. Prentice Hall, 2008.
Walter Savitch. Problem solving with C++, 10th edition. Addison Wesley, 2014.

Recommended books can be requested online, via the Library catalogue.

4.3 Electronic reserves (e-reserves)


E-reserves can be downloaded from the library catalogue. More information is available at:
http://libguides.unisa.ac.za/request/request

8 8
COS1511/101/3/2021

4.4 Library services and resources information


The Unisa Library offers a range of information services and resources:

for brief information go to: https://www.unisa.ac.za/library/libatglance


for more detailed Library information, go to
http://www.unisa.ac.za/sites/corporate/default/Library
for research support and services (e.g. Personal Librarians and literature
search services), go to
http://www.unisa.ac.za/sites/corporate/default/Library/Library-
services/Research-support

The Library has created numerous Library guides: http://libguides.unisa.ac.za


Recommended guides:

request and find library material/download recommended material:


http://libguides.unisa.ac.za/request/request
postgraduate information services: http://libguides.unisa.ac.za/request/postgrad
finding and using library resources and tools:
http://libguides.unisa.ac.za/Research_skills
Frequently asked questions about the Library: http://libguides.unisa.ac.za/ask
Services to students living with disabilities:
http://libguides.unisa.ac.za/disability

Important contact information:

https://libguides.unisa.ac.za/ask - Ask a Librarian


Lib-help@unisa.ac.za - technical problems accessing library online services
Library-enquiries@unisa.ac.za - general library related queries
Library-fines@unisa.ac.za - for queries related to library fines and payments

5 STUDENT SUPPORT SERVICES


The Study @ Unisa brochure is available on myUnisa: www.unisa.ac.za/brochures/studies
This brochure has all the tips and information you need to succeed at distance learning and,
specifically, at Unisa.
Please check Additional Resources on myUnisa regularly for documents that will assist you if you
have problems installing software, using the compiler, writing a program, etc. You will also find
extra help for the examination there. You can also check the FAQs to see if there is a
solution to your problems.

9 9
5.1 E-Tutors

Unisa offers online tutorials (e-tutoring) to students registered for modules at NQF level 5 and 6,
this means qualifying first year and second year modules.

Once you have been registered for a qualifying module, you will be allocated to a group
of students with whom you will be interacting during the tuition period as well as an e-tutor who
will be your tutorial facilitator. Thereafter you will receive a SMS informing you about your group,
the name of your e-tutor and instructions on how to log onto myUnisa in order to receive
further information on the e-tutoring process. If you login into myUnisa you will notice that your
group site has been added there. Your tutor will be able to assist you there. For example, if you
were allocated in group 4, the group site will be named COS1511-20-Y1-4E. You can use
the discussion forum to discuss module content issues with your tutor as well as with
students belonging to that group. You will also find the contact details of your tutor. If you have
content related problems (that is, the problem with the material in your study guide that
you do not understand), please contact your e-tutor.
Online tutorials are conducted by qualified E-Tutors who are appointed by Unisa and are offered
free of charge. All you need to be able to participate in e-tutoring is a computer with internet
connection. If you live close to a Unisa regional Centre or a Telecentre contracted with Unisa,
please feel free to visit any of these to access the internet. E-tutoring takes place on myUnisa
where you are expected to connect with other students in your allocated group. It is the role of the
e-tutor to guide you through your study material during this interaction process. For you to get the
most out of online tutoring, you need to participate in the online discussions that the e- tutor will
be facilitating.
There are modules that students have been found to repeatedly fail, these modules are
allocated face-to-face tutors and tutorials for these modules take place at the Unisa regional
centres. These tutorials are also offered free of charge, however, it is important for you to
register at your nearest Unisa Regional Centre to secure attendance of these classes.

5.2 Free computer and internet access


Unisa has entered into partnerships with establishments (referred to as Telecentres) in various
locations across South Africa to enable you (as a Unisa student) free access to computers and the
Internet. This access enables you to conduct the following academic related activities:
registration; online submission of assignments; engaging in e-tutoring activities and signature
courses; etc. Please note that any other activities outside of these are for your own costing e.g.
printing, photocopying, etc. For more information on the Telecentre nearest to you, please visit
www.unisa.ac.za/telecentres.
5.3 Downloading study material and software
One of the requirements for studying at the School of Computing is to have regular access to
myUnisa. You are therefore expected to download any study material from the internet that, for
whatever reason, is not available on paper in time. You may download it from myUnisa. The

10 10
study material is updated regularly, thus you need to check the COS1511 website at least once a week
on myUnisa.
Because COS1511 is a semester module, time is of the utmost importance. You should start
studying the module immediately after registration. This tutorial letter, the Study Guide and the
software are most important.
The Study Guide is available on myUnisa. If you do not receive a study guide immediately after
registration, you should download it from myUnisa.

The software should also be downloaded from the School of Computing's Osprey server:
http://osprey.unisa.ac.za/. From the home page, click on the SoC Registered Students link.
Then, if you haven't done so already, select your modules and click on the Submit button. You
should then see a link to the Open-source software repository under Resources.The Drawing
Variable Diagrams Tutorial can also be downloaded from myUnisa under Additional Resources for
COS1511.
When you want to use myUnisa for the first time, you have to register. Go to my.unisa.ac.za and click
on “Join myUnisa”. Then follow the instructions on the screen. You will get a password for
future use. We also suggest that you get your myLife email address as soon as possible. See the Study
@ Unisa brochure for instructions. The University communicates with you via this email address.
You also get notified about important announcements for COS1511 via this email address. Please
check your myLife email regularly.

5.4 Announcements on myUnisa


We urge you to access myUnisa on a regular basis. We put announcements on myUnisa regarding
the module on a regular basis.

5.5 Installation of the software

Once you have access to a computer, you should install the software for this module on the
computer. (If you will be using one of Unisa's computer laboratories, the software will already
be installed). The software that you need for COS1511, can be downloaded from the School
of Computing's Osprey server: http://osprey.unisa.ac.za/. From the home page, click on the SoC
Registered Students link. Then, if you haven't done so already, select your modules and click on
the Submit button. You should then see a link to the Open-source software repository
under Resources.
Drawing Variable Diagrams Tutorial
In addition, you will also receive a CD called Drawing Variable Diagrams Tutorial. This CD contains a
tutorial to show you how to draw variable diagrams. It is an interactive tutorial that will show you how
to draw the variable diagrams illustrated in the Study Guide. The CD will install automatically when you
insert it in the CD drive of your computer. If you have not received this CD, this software can be
downloaded from myUnisa under Additional Resources.

In the Study Guide for COS1511, the tutor icon shown here will indicate that you should load
the Drawing Variable Diagrams Tutorial (with the corresponding activity or sub-activity
number) and watch the effect of the program statements on the variables. We strongly encourage
you to use the Drawing Variable Diagrams Tutorial, since research has shown that students who
draw their own variable diagrams to understand or debug programs, achieve better results.

11 11
6 STUDY PLAN
Use your Study@Unisa brochure for general time management and planning skills. Remember to
highlight or indicate all the words or phrases you think are key points. You can use these and the
headings to make your concept maps or summaries whichever you prefer.
After installing the C++ software, start at the Preface and then Lesson 1 of the Study Guide. Each
lesson in the Study Guide contains Activities and Sub-activities. Because you may not have done
programming before, you probably will not be able to do the Activities the first time you try them. Do
not worry! Work through the Sub-activities. They will lead you step by step to do the Activities.
Please use the Drawing Variable Diagrams Tutorial that you have received with your study material
when the Study Guide directs you to do so. You will benefit greatly from the tutorial.
We recommend that you use the following study programme as a starting point. You will probably need
to adapt this schedule, taking into account your other modules and your personal
circumstances. You are expected to spend AT LEAST 8 hours per week on COS1511.

This tutorial is organized such that assignment 1 and 2 covers the entire lessons of
the study guide, same applies for assignment 3 and 4.

Week Lessons in the study guide


1 Install software.
Study lesson 1
2 Lessons 2, 3 and 4

3 Lessons 5, 6, and 7

4 Lessons 8, 9, 10 and 11

5 Lessons 12, 13 and 14

6 Lessons 15 and 16

7 Lessons 17, 18 and19

8 Lessons 20, 21 and 22

9 Lessons 23 -30
Next Lesson 1- Lesson 30
Do Revision

Please remember that COS1511 is a programming module, and therefore requires a lot of
practical work. Programming modules also require much more time than other modules with no
practical work. You will probably find that you need to work hard and consistently throughout the
semester to develop the necessary programming skills. Plan to spend at least 8 hours
per week on this module.

12 12
COS1511/101/3/2021

7 PRACTICAL WORK
The assignments include practical programs that you have to write, compile and run. All students must
have access to a computer in order to do COS1511 successfully. The computer must have a CD-ROM
drive. A description of the requirements for the computer appears on the COS1511 website.

This module does not require any work integrated learning. However, it is necessary to do
extensive practical work on a computer for this module. The Study Guide is compiled in such a
way that you have to continually design computer programs and get them to work.
The examination, on the other hand, is a purely written examination and does not involve doing
any work on the computer. There are no practical sessions that students need to attend during the
year. The Unisa computer laboratories in a number of centres are available to students for
the practical work of COS1511. Please contact your nearest regional office about this. Contact
information about the regional offices can be found in the Unisa brochure Study @ Unisa.

8 ASSESSMENT
8.1 Assessment criteria
Assignments are seen as part of the learning material for this module. Whether you work
on your own, work together in groups, attend the tutor sessions, etc., you are actively
learning. Please look at the outcomes and assessment criteria for the module before you
do the assignments. This will help you to understand what is required in the assignments.

You will receive feedback on your individual assignments (for assignment 1,2, 3 and 4). Tutorial
letter 201, 202, 203 and 204 with the solutions to the assignments will be available on myUnisa.
You are welcome to work together in small groups. However, we expect every member of the
group to write and submit the programs on his or her own. So, discuss the problem, find
solutions, etc., in the group, but then do your own programming and submit your own effort. You
will learn to program only if you sit down in front of the computer, type in the code, debug the
program and get it to work. It is dishonest to submit the work of somebody else as your own and
such unethical behaviour does not become our profession. We urge you not to buy assignment
solutions from students advertising on the forum. It may help you to get a better semester mark,
but it will not help you in the exam if you have not tried the program yourself.
Plagiarism is the act of taking words, ideas and thoughts of others and passing them off as your
own. This also means that you are not allowed to copy the solutions and submit them as if they
were your own work. It is a form of theft which involves a number of dishonest academic
activities. The Disciplinary Code for Students (2004) is given to all students at registration. You
are advised to study the Code, especially Sections 2.1.13 and 2.1.14 (2004:3-4). Kindly read the
University’s Policy on Copyright Infringement and Plagiarism as well.

Assignments are not accepted via fax or email.

13
We urge you to do and submit practical assignments; otherwise you will find it very
difficult in the examination. For these assignments you have to write, compile and run
programs using the software that you have installed. Students must submit these
assignments via myUnisa. Assignment 1 and 2 must be submitted in PDF format. See
Additional Resources on the CO1511 course website for instructions on how to create
an assignment as a PDF file.

We do not necessarily mark all questions. You will get 0% if you do not submit the
questions that are marked.

The semester system does not allow for late submission of assignments. However, we
give 4 days’ automatic extension for Assignment 1 and 2. This means that you
may submit the assignment up to 3 days after the due date, without making
special arrangements with the lecturers. Although myUnisa will give you a message
to say that your assignment is late, the assignment will still be accepted by the
myUnisa system.

The programs must be written in C++. You may not use any other high-level language
for COS1511. Your programs must follow the programming style used in the
Study Guide. In the assignments and the examination, marks are awarded for
programming comments, programming style, syntax and logic.

The input data as specified in the questions will be used to test your programs.

No marks are allocated for programs that do not compile.


8.2 Assessment plan
To obtain exam admission, you have to submit at least one assignment by the due date.
This module has three assignments and a final written examination at the end of the semester.
The marks that you obtain for Assignments 1, 2 and 3 form the semester mark for COS1511. The
semester mark forms 20% of the final mark for the module.
The weights of the COS1511 assignments are indicated in the table below:

Assignment Weight
number
1 30%
2 20%
3 30%
4 20%

An example follows: Suppose a student gets 60% for Assignment 1, 45% for Assignment 2,
65% for Assignment 3, and 40% for assignment 4. In order to calculate the semester mark, the
mark obtained for the specific assignment is multiplied by the weight. This then forms part
of the 20% that the semester mark contributes to the final mark.

14
Therefore:
Assignment Marks obtained Weight Contribution to year
mark
1 60% 30% 60/100x30/100x20 3.6
2 30% 20% 30/100x20/100x20 1.2
3 70% 30% 70/100x30/100x20 4.2
4 45% 20% 45/100x20/100x20 1.8
Total 10.8

In this example, the student has a semester mark of 10.8 out of


20.
You will pass this module provided that the mark you obtain in the examination is 40% or
higher
AND your final mark is 50% or more. Your marks for this module will be calculated as
follows:
Final mark (out of 100%) = semester mark from assignments (20%) + exam mark
(80%)

The semester mark will not form part of the final mark of a supplementary
examination.

8.3Assignment numbers
8.3.1
General assignment numbers

Assignments are numbered consecutively starting from 01. The assignments are marked and
a percentage is awarded according to your achievement. Please make an effort to do
the assignments, as it will benefit you greatly for the examination. When you plan your studies,
take note of the submission dates of assignments.

8.3.2 Unique assignment


All assignments have unique numbers. When you submit through myUnisa, you will be asked
to enter the unique number for each assignment. You will find the unique numbers
with each assignment in section 8.4 of this tutorial letter.

8.4 Assignment due


dates
The following is a breakdown of the assignments as the formal assessment activities and
their due dates during this year:

Assignment Unique number Due date

1 534568 29 April 2021

15
2 645667 31 May 2021

3 841712 31 August 2021

4 862799 04 October
2021

*The assignments are provided in this tutorial letter.

8.5 Submission of
assignments

 Assignments 1, 3 and 4 consist of questions to be implemented and the program code


and output to be assembled in a word file, converted to PDF and then electronically
submitted via myUnisa. There is an automatic four days extension for Assignment 1
and 3.
 Assignment 2 consists of 60 multiple choice questions (MCQs). These assignments (2
and 4) has to be submitted ON TIME. The assignments can either submitted by Mobile
MCQ submission or electronically via myUnisa.

8.6 Assignment 1
SUBMISSION: Electronically via myUnisa

Please note that we automatically give four days extension for this assignment. It will be
to your own advantage to check after a few days whether the assignment has been registered
on the system. If you have not completed the assignment by the extension date, submit
whatever you have completed – you will get marks for everything that you have done.
If myUnisa is off-line when you want to submit the assignment, you need not contact us,
because we will be aware of it. Simply submit it as soon as myUnisa is available again.

DUE DATE 29 April 2021

UNIQUE NUMBER 534568

EXTENSION There is an automatic extension until 03 May. You do


not need to phone or send an e-mail to request
automatic extension

TUTORIAL MATTER Study Guide, Lessons 1 – 16

CONTRIBUTION WEIGHT TO 30%


SEMESTER MARK
QUESTIONS Practical exercises

16
IS YOUR SOFTWARE INSTALLED?
If you struggle to install the software, please contact your e-tutor.
Question 1

Find a good cookbook. Read the instructions for your favourite dish. Write a program to display the recipe on the
screen but with a difference. The quantity of each ingredient must be multiplied by a value entered from the
keyboard.

For example, if the recipe needs 2 cups of flour the output displayed will be something like this

Please enter the factor to multiply the ingredients with : 4


Recipe name
Ingredients
// other ingredients
8 cups flour
Method

The program has the following structure:


 Declare an int variable named mFactor to store the value with which the quantity of each ingredient
must be multiplied.
 The program must make use of a cin statement to input a value from the keyboard and store it in mFactor.
Submit both your program and output.

Question 2

A teacher at Leva Primary School needs to divide her class in different group sizes according to the activity they
have to do. This will help her to prepare workstations for each group. For example, for art projects the class has
to be divided in groups of 6; for science projects the class has to be divided in groups of 4. She asked you to write
a program to determine the number of groups as well as the number of pupils who are left to form a smaller group.
There are 56 pupils in the class.

The program has the following structure:


 Declare three int variables nrPupils, nrGroups, and nrLeft. nrPupils represents the number of
pupils in a class, nrGroups represents the number of groups the class is divided into, and nrLeft
represents the number of pupils, if any, who are in the remaining smaller group.
 Assign the value 56 to nrPupils.
 Declare an int variable groupSize that is used by a cin statement to input a value from the keyboard
and store the size of the groups the teacher requested. Display an appropriate message. E.g. Please
enter the size of each group?
 Write the statement to calculate the number of groups of size groupSize.
 Write the statement to calculate the number of pupils who are in the remaining smaller group.

The output of the program must be displayed as follows:


There are 9 groups consisting of 6 pupils
There are 3 remaining pupils

Submit both your program and output.

Question 3

You are requested to write a very simple calculator. Your calculator should be able to handle the five basic
mathematic operations – add, subtract, multiply, divide and modulus – on two input values.

17
Your program should have the following structure:
 Ask the user to enter two float variables named var1 and var2
 Ask the user to enter a character variable named operation to represent the operation to be performed
on the two variables.
 Perform the appropriate operation by using if-statements
 The output must be given in fixed-point notation with two digits after the decimal point.

A typical run is displayed below:


Please enter the first float value: 35.6
Please enter the second value: 24.12
Please enter the operation required : +
The sum of 35.6 and 24.12 is 59.72

Submit both your program and output.

Question 4

The Computer Science Department follows certain criteria when a student learns to program. A number of
programming exercises must be worked through. To proceed to the next exercise a student has to obtain a mark
of 50% or more and must have completed 5 or more program runs. You are requested to write a program to validate
if a student can proceed to the next program.

Your program should have the following structure:


 Declare two integer variables programsDone and result.
 Validate the data captured for the two variables using a while loop.
 The loop should be repeated until the value of result is greater than or equal to 50 and the value of
programsDone is greater than or equal to 5.
 Display a message like "Good! You can now proceed to the next exercise"

Submit both your program and output.


Question 5

Include the for loop below in a small program and complete the program. The loop should execute 10 times. Do
not change the for loop below. Compile and run your program to see for yourself that it works. You do not have
to submit this program and output.

for (int i = 1; i <= n; i++)


cout << i * i;

Now convert the for loop into a while loop and add any variable initialisations that you think are necessary.
Compile and run your program and submit only the program containing the while loop and its output.

Question 6

A bookshop gives discount to customers as follows:


 Students get 10% discount,
 Book dealers get 12% discount and
 Pensioners get 15% discount.
 All other customers get 10% discount only if their total purchases are more than R200.

You are requested to write two versions of a program that calculates and displays the final amount that is due, after
discount.

(i) The first version of the program uses a switch statement to implement the above program.
(ii) The second version of the program uses nested-if statements.
18
Hint:
Use the following variables:
float amount; // the amount due before discount
char customerType; // the type of customer: 'S' (student) or
// 'D' (dealer) or 'P' (pensioner) or
// 'O'(other)
float discount, finalAmount;

Submit both programs and their output.

Question 7

The following code is supposed to display the positive even numbers less than 12. That is, it will output the numbers
2, 4, 6, 8 and 10. However, there is a logical error in the code. Explain what the output of the code below will be.
Then write a small program including the code below and make the necessary changes to fix the code so that it
displays what it is intended to display. Ensure that your program works correctly. Only submit the program, not the
output.

Hint: Use variable diagrams to trace the program to help you find the logical error.

int x = 1;
while (x != 12)
{
cout << x << endl;
x = x + 2;
}

Submit your program and output.

Question 8

The following incomplete program first asks the user to enter the number of items he/she has eaten today and then
to enter the number of calories for each item. It then calculates the number of calories he/she has eaten for the day
and displays the value.

#include <iostream>
using namespace std;
int main()
{
int numberOfItems;
int count; //loop counter for the loop
int caloriesForItem;
int totalCalories;
cout << "How many items did you eat today? ";
cin >> numberOfItems;
cout << "Enter the number of calories in each of the "
<< numberOfItems << " items eaten: " << endl;
// ------------- Your code --------------
cout << "Total calories eaten today = " << totalCalories;
return 0;
}

You have to complete the code. First complete the code by using a while loop to read in the calories of all the
items. Compile and run your program and submit only the code that you added and the output. Then change you
program to use a for loop to read in the calories of all the items. Compile and run the program again and submit
only the code that you added and the output. Use the variables that have already been defined in the given program.
Test your program by entering 7 for the number of items and the following values for the calories:
19
7 120 60 150 600 1200 300 200

If your logic is correct, the following will be displayed:


Total calories eaten today = 2631

Submit your program and output.

Question 9

Suppose a new member of the city council has to be chosen from three candidates and suppose there are 4 voting
stations. We need a C++ program that will count the votes for every candidate and display the result. At every
voting station the voters vote by choosing A, B or C on a ballot paper. The voting officer must enter the votes into
the program so that they can be counted. X is entered when all the votes at a specific voting station have been
entered.

The program has the following structure:

 The three totals and the number of spoilt votes are initialised to 0. Use the following integer variables
votesForA, votesForB, votesForC, spoiltVotes
 Use a for loop, going from 1 to the number of voting stations.
 Inside this loop is a while loop. A prompting message appears on the screen, asking the voter for which
candidate he or she wants to vote. The choice of the voter is then input.
 Inside the while loop is a switch statement to increment the correct total. The default option is used
to count the number of spoilt votes.
 The while loop is exited when X is entered for the choice.
 When the for loop is exited, the three totals and the number of spoilt votes are displayed.
 Display the results as follows:

Total candidate A: xxx


Total candidate B: xxx
Total candidate C: xxx
Total spoilt votes: xxx

Run your program with the input given below and submit printouts of the program and output. (We write the data
of each voting station in one line, but you will possibly enter the values on separate lines.)

B B B A C X
A B C D Y B X
B A C C B X
A B X

Submit your program and output.

Question 10

Draw a series of variable diagrams for the program below using the conventions of the Study Guide. Assume that
the following input is given: 2010 t

1 #include <iostream>
2 #include <string>
3 using namespace std;
4 int main()
5 {
6 int year; char code;
7 bool book = true; float discount = 0.20;
8 cin >> year >> code;
9 switch (year)
20
10 {
11 case 2008: case 2009:
12 if (code == 'c')
13 if (!book)
14 discount += 0.20;
15 break;
16 case 2010:
17 if (book)
18 if (code == 't')
19 {
20 book = false;
21 code = 'g';
22 }
23 case 2011:
24 if (discount > 0.20 || code == 'g')
25 discount = 0.15;
26 else
27 discount += 0.10;
28 default:
29 discount = 0.25;
30 code = 'b';
31 book = true;
32 }
33 discount = 0.35;
34 cout << year << " " << code << " " << book << " "
<< discount << endl;
35 return 0;
36 }

End of Assignment 1

8.7 Assignment 2

MULTIPLE CHOICE ASSIGNMENT


SUBMISSION: Either by Mobile MCQ submission or electronically via myUnisa.
Please note that Assignment 2 has to be submitted ON TIME in order to gain examination
admission. It will be to your own advantage to check after a few days whether the assignment
has been registered on the system. If you have not completed the assignment by the due date,
submit whatever you have completed – you will get marks for everything that you have done.

21
If you want to submit the assignment electronically and myUnisa is off-line during that time, you
need not contact us, because we will be aware of it. Simply submit it as soon as myUnisa is
available again.
Note the assignment unique number below – if you submit through myUnisa you will be asked
to enter it. If you submit by post, please fill it in where it is requested on the mark reading sheet.

DUE DATE 31 May 2021

UNIQUE NUMBER 645667

EXTENSION There is NO extension for this assignment.

TUTORIAL MATTER Study Guide, Lessons 24 – 29

CONTRIBUTION WEIGHT TO 20%


SEMESTER MARK
QUESTIONS 60 questions. Choose one option in every question.
 
QUESTION 1

Consider the following declarations:


const int NUMELS 10;
int values[NUMELS];
Which of the following array accesses is valid?

1. values[-1]

2. values[0]

3. values[10]

4. values[11]

QUESTION 2

Consider the following code segment that finds the maximum value store in an array named grade of size NUMELS.
What is the missing line of code indicated by the blank line?
___________
for (i = 1; i < NUMELS; i++)
if (grade[i] > maximum)
maximum = grade[i];

1. maximum = grade[0];

2. maximum = grade[1];

3. maximum = 100;

4. maximum = grade[NUMELS];

QUESTION 3

Considering the following declarations:


22
const int NUMELS 10;
int values[NUMELS];
Which of the following C++ statements correctly outputs the seventh element of the array?

1. cout << values[6];

2. cout << values[7];

3. cout << values[8];

4. cout << values << 7;

QUESTION 4

Consider the following declarations:


const int ARRAYSIZE = 7;
float length[ARRAYSIZE] = {7.8, 6.4, 4.9, 11.2};
What is the value of length[1] and length[4]?

1. 7.8 and 11.2, respectively

2. 6.4 and 11.2, respectively

3. 6.4 and 0, respectively

4. 7.8 and 0, respectively

QUESTION 5

Consider the following declaration:


char codes[] = {'s', 'a', 'm', 'p', 'l', 'e'};
Which of the following array declarations is equivalent to the above declaration?

1. char codes[] = "sample";

2. char codes[5] = {'s', 'a', 'm', 'p', 'l', 'e'};

3. char codes[6] = {'s', 'a', 'm', 'p', 'l', 'e'};

4. char codes[7] = {'s', 'a', 'm', 'p', 'l', 'e'};

QUESTION 6

Which of the following function header lines is valid for a function called findMax that finds and returns the
maximum value stored in an array of integers that is passed in as a parameter?

1. int findMax(int [])

2. int findMax(int values[])

3. int findMax(int)

4. int findMax([])

QUESTION 7
23
Which of the following declarations correctly declares a two dimensional array of floats named prices that has
10 rows and 5 columns?

1. const int NUMROWS = 10;

const int NUMCOLS = 5;


float prices[NUMROWS + NUMCOLS];

2. const int NUMROWS = 10;

const int NUMCOLS = 5;


float prices[NUMROWS,NUMCOLS];

3. const int NUMROWS = 10;

const int NUMCOLS = 5;


float prices[NUMCOLS][NUMROWS];
4. const int NUMROWS = 10;

const int NUMCOLS = 5;


float prices[NUMROWS][NUMCOLS];

QUESTION 8

Assuming the following declarations:


const int NUMROWS = 3;
const int NUMCOLS = 4;
int val[NUMROWS][NUMCOLS] = {8,16,9,52,3,15,27,6,14,25,2,10};
Which of the following loops correctly outputs each element of the array in row order?

1. for (i = 0; i < NUMROWS; i++)

{
for (j = 0; j < NUMCOLS; j++)
cout << setw(4) << val[i][j];
cout << endl;
}
2. for (i = 0; i < NUMROWS; i++)

{
cout << setw(4) << val[i][j];
cout << endl;
}
3. for (i = 0; i < NUMCOLS; i++)

{
cout << setw(4) << val[i][j];
cout << endl;
}
4. for (i = 0; i < NUMROWS*NUMCOLS; i++)

{
cout << setw(4) << val[i][j];
cout << endl;
}

QUESTION 9

24
Which of the following function header correctly includes a two dimensional array as its parameter?

1. void display(int [][COLS]);

2. void display(int [ROWS][]);

3. void display(int [][]);

4. void display(int [ROWS][COLS]);

QUESTION 10

What will be the output of this program?

#include <iostream>
using namespace std;
int main()
{
int array1[] = {1200, 200, 2300, 1230, 1543};
int array2[] = {12, 14, 16, 18, 20};
int temp, result = 0;
for (temp = 0; temp < 5; temp++)
{
result += array1[temp];
}

for (temp = 0; temp < 4; temp++)


{
result += array2[temp];
}
cout << result;
return 0;
}

1.6553
2.6533
3.6522
4.12200
 
QUESTION 11

What is the output of this program?

#include <iostream>
using namespace std;
int main ()
{
int array[] = {0, 2, 4, 6, 7, 5, 3};
int n, result = 0;
for (n = 0; n < 8; n++)
{
result += array[n];
}
cout << result;
return 0;
}

1. 24

25
2. 25
3. 26
4. 27

QUESTION 12

What is the output of this program?

#include <iostream>
using namespace std;
int main()
{
char str[5] = "ABC";
cout << str[3];
cout << str;
return 0;
}

1. ABC
2. ABCD
3. AB
4. C

QUESTION 13

Which of the following statements declares alpha to be an array of 25 elements of the type int?

1. int alpha[25];
2. int array alpha[25];
3. int alpha[2][5];
4. int array alpha[25][25];

QUESTION 14

Assume you have the following declaration


char nameList[100];
Which of the following ranges is valid for the subscript of the array nameList?

1. 0 through 99
2. 0 through 100
3. 1 through 100
4. 1 through 101

QUESTION 15

Assume you have the following declaration


int beta[50];
Which of the following is a valid element of beta?

1. beta['2']
2. beta["50 "]
3. beta[0]
4. beta[50]

QUESTION 16

26
Assume the following declarations
const int NUMROWS = 3;
const int NUMCOLS = 4;
int val[NUMROWS][NUMCOLS]={8,16,9,52,3,15,27,6,14,25,2,10};
Which statement will change the value of the element with the value 27 to 55.

1. val[0][1] = 55;
2. val[1][2] = 55;
3. val[2][1] = 55;
4. val[1][1] = 55;

QUESTION 17

Suppose that sales is an array of 50 elements of type float. Which of the following correctly initializes the array
sales?

1. for (int 1 = 1; j <= 49; j++)


sales[j] = 0;
2. for (int j = 1; j <= 50; j++)
sales[j] = 0;
3. for (int j = 0; j <= 49; j++)
sales[j] = 0.0;
4. for (int j = 0; j <= 50; j++)
sales[j] = 0.0;

QUESTION 18

Suppose that list is an array of 10 elements of type int. Which of the following codes correctly outputs all the
elements of list?

1. for (int j = 1; j < 10; j++)

cout << list[j] << " ";


cout << endl;
2. for (int j = 0; j <= 9; j++)

cout << list[j] << " ";


cout << endl;
3. for (int j = 1; j < 11; j++)

cout << list[j] << " ";


cout << endl;
4. for (int j = 1; j <= 10; j++)

cout << list[j] << " ";


cout << endl;

QUESTION 19

What is the output of the following C++ code?

int list[5] = {0, 5, 10, 15, 20};


int j;
for (j = 0; j < 5; j++)
cout << list[j] << " ";
cout << endl;
27
1. 0 1 2 3 4
2. 0 5 10 15
3. 0 5 10 15 20
4. 5 10 15 20

QUESTION 20

What is the value of alpha[2] after the following code executes?


int alpha[5];
int j;

for (j = 0; j < 5; j++)


alpha[j] = 2 * j + 1;

1. 1
2. 4
3. 5
4. 6

QUESTION 21

What is the output of the following C++ code?

int alpha[5] = {2, 4, 6, 8, 10};


int j;
for (j = 4; j >= 0; j--)
cout << alpha[j] << " ";
cout << endl;

1. 2 4 6 8 10

2. 4 3 2 1 0

3. 8 6 4 2 0

4. 10 8 6 4 2

QUESTION 22

What is the output of the following C++ code?


int list[5] = {0, 5, 10, 15, 20};
int j;

for (j = 1; j <= 5; j++)


cout << list[j] << " ";
cout << endl;

1. 0 5 10 15 20

2. 5 10 15 20 0

3. 5 10 15 20 20

4. Code results in subscript out-of-range

QUESTION 23

28
Suppose that gamma is an array of 50 elements of type int and j is an int variable. Which of the following for
loops sets the subscript of gamma out-of-range?

1. for (j = 0; j <= 49; j++)

cout << gamma[j] << " ";


2. for (j = 1; j < 50; j++)

cout << gamma[j] << " ";


3. for (j = 0; j <= 50; j++)

cout << gamma[j] << " ";


4. for (j = 0; j <= 48; j++)

cout << gamma[j] << " ";

QUESTION 24

Consider the following declaration


int alpha[5] = {3, 5, 7, 9, 11};
Which of the following is equivalent to this statement?

1. int alpha[] = {3, 5, 7, 9, 11};


2. int alpha[] = {3 5 7 9 11};
3. int alpha[5] = [3, 5, 7, 9, 11];
4. int alpha[] = (3, 5, 7, 9, 11);

QUESTION 25

Which of the following correctly declares name to be a character array and stores "William" in it?

1. char name[6] = "William";


2. char name[7] = "William";
3. char name[8] = "William";
4. char name[8] = 'William';

QUESTION 26

Consider the following statement:


float alpha[10][5];
The number of elements of alpha is ____.

1. 15
2. 50
3. 100
4. 150

QUESTION 27

Consider the statement


int list[10][8];
Which of the following about list is true?

1. list has 10 rows and 8 columns.


2. list has 8 rows and 10 columns.
3. list has a total of 18 elements.

29
4. list has a total of 108 elements.

QUESTION 28

Consider the following statement:


int alpha[25][10];.
Which of the following statements about alpha is true?

1. Rows of alpha are numbered 0...24 and columns are numbered 0...9.
2. Rows of alpha are numbered 0...24 and columns are numbered 1...10.
3. Rows of alpha are numbered 1...24 and columns are numbered 0...9.
4. Rows of alpha are numbered 1...25 and columns are numbered 1...10.

QUESTION 29

Which of the following correctly declares and initializes alpha to be an array of four rows and three columns with
the element type int?

1. int alpha[4][3] = {{0,1,2} {1,2,3} {2,3,4} {3,4,5}};


2. int alpha[4][3] = {0,1,2; 1,2,3; 2,3,4; 3,4,5};
3. int alpha[4][3] = {0,1,2:1,2,3:2,3,4:3,4,5};
4. int alpha[4][3] = {{0,1,2}, {1,2,3}, {2,3,4}, {3,4,5}};

QUESTION 30

After the following statements execute, what are the contents of matrix?

int matrix[3][2];
int j, k;

for (j = 0; j < 3; j++)


for (k = 0; k < 2; k++)
matrix[j][k] = j + k;

1. 0 0
1 1
2 2
2. 0 1
2 3
4 5
3. 0 1
1 2
2 3
4. 1 1
2 2
3 3

QUESTION 31

Given the following declaration:


int j;
int sum;
float sale[10][7];
which of the following correctly finds the sum of the elements of the fifth row of sale?

1. sum = 0;
for(j = 0; j < 7; j++)
30
sum = sum + sale[5][j];

2. sum = 0;
for(j = 0; j < 7; j++)
sum = sum + sale[4][j];
3. sum = 0;
for(j = 0; j < 10; j++)
sum = sum + sale[5][j];
4. sum = 0;
for(j = 0; j < 10; j++)
sum = sum + sale[4][j];

QUESTION 32

Given the following declaration:


int j;
int sum;
float sale[10][7];
which of the following correctly finds the sum of the elements of the fourth column of sale?

1. sum = 0;
for(j = 0; j < 7; j++)
sum = sum + sale[j][3];
2. sum = 0;
for(j = 0; j < 7; j++)
sum = sum + sale[j][4];
3. sum = 0;
for(j = 0; j < 10; j++)
sum = sum + sale[j][4];
4. sum = 0;
for(j = 0; j < 10; j++)
sum = sum + sale[j][3];

QUESTION 33

Consider the following declaration:


char str[15];
Which of the following statements stores "Blue Sky" into str?

1. str = "Blue Sky";


2. str[15] = "Blue Sky";
3. strcpy(str, "Blue Sky");
4. strcpy("Blue Sky");

QUESTION 34

The statement ____ declares and initializes a string variable named postalCode

1. string postalCode = "";


2. postalCode = "";
3. init postalCode = "";
4. declare postalCode = "";

QUESTION 35

31
The statement ____ assigns the number of characters contained in the message variable to an int variable named
numChars.

1. numChars = message;
2. numChars == message.size();
3. numChars = message.size();
4. numChars = size.message;

QUESTION 36

The statement ____ removes the first two characters from the message variable using the erase function.

1. message.erase(0,2);
2. message.erase(0,2,2);
3. message.erase(1,2);
4. message.erase(2);

QUESTION 37

The statement ____ removes the first two characters from the message variable using the replace function.

1. message.replace(0,2);
2. message.replace(1,2,"");
3. message.replace(0,2,"");
4. message.replace(0,2,2);

QUESTION 38

The statement ____ assigns the first four characters of a string variable named address to a string variable named
streetNum.

1. streetNum = address.substr(1,4);

2. streetNum = address.substr(0,4);

3. streetNum = address.substr(1,5);

4. streetNum = address.substr(0,3);

QUESTION 39

The statement ____ changes the contents of the word variable from “mend” to “amend".

1. word.insert(0,"a");
2. word.append(0,"a");
3. word.insert(1,"a");
4. word.append(1,"a");

QUESTION 40

The elements of a struct are called the ____ of the struct.

1. variables

32
2. identifiers

3. elements

4. fields

QUESTION 41

Which of the following struct definitions is correct in C++?

1. struct studentType

{
int ID;
};

2. struct studentType

{
string name;
int ID;
float gpa;
}
3. int struct studentType

{
ID;
}
4. struct studentType

{
int ID = 1;
};

QUESTION 42

Consider the following struct definition:


struct rectangleData
{
float length;
float width;
float area;
float perimeter;
};
Which of the following variable declarations is correct?

1. rectangle rectangleData;
2. struct rectangleData();
3. rectangleData myRectangle;
4. rectangleData rectangle = new rectangleData();

QUESTION 43

Consider the following struct definition:


struct temp
{
int b;
};
33
temp s[50];

The correct syntax to access the member of the ith structure in the array of
structures is?

1. s.b.[i];

2. s.[i].b;

3. s.b[i];

4. s[i].b;

QUESTION 44

The syntax for accessing a struct member is structVariableName ____.

1. .memberName

2. *memberName

3. [memberName]

4. $memberName

QUESTION 45

Consider the following statements:


struct rectangleData
{
float length;
float width;
float area;
float perimeter;
};
rectangleData bigRect;
Which of the following statements correctly initializes the element length of bigRect?

1. bigRect = {10};

2. bigRect.length = 10;

3. length[0]= 10;

4. bigRect[0]= 10

QUESTION 46

Consider the following statements:


struct rectangleData
{
float length;
float width;
float area;
float perimeter;
};

34
rectangleData bigRect;
Which of the following statements is valid in C++?

1. cin >> bigRect;


2. cin >> bigRect.length;
3. perimeter = 2 * (length + width);
4. area = length * width;

QUESTION 47

Consider the following statements:


struct personalInfo
{
string name;
int age;
float height;
float weight;
};
struct commonInfo
{
string name;
int age;
};
personalInfo person1, person2;
commonInfo person3, person4;
Which of the following statements is valid in C++?

1. person1 = person3;
2. person2 = person1;
3. person2 = person3;
4. person2 = person4;
5.

QUESTION 48

Consider the following statements:


struct studentType1
{
string name;
int ID;
float gpa;
};
struct studentType2
{
string name;
int ID;
float gpa;
};
studentType1 student1, student2;
studentType2 student3, student4;
Which of the following statements is valid in C++?

1. student2 = student3;
2. student1 = student4;
3. student2.ID = ID;
4. student1.ID = student3.ID;

QUESTION 49

35
Consider the following statements:
struct rectangleData
{
float length;
float width;
float area;
float perimeter;
};
rectangleData bigRect;
rectangleData smallRect;

Which of the following statements is legal in C++?

1. if (bigRect == smallRect)
2. if (bigRect != smallRect)
3. if (bigRect.length == width)
4. if (bigRect.length == smallRect.width)

QUESTION 50

Consider the following statements:


struct circleData
{
float radius;
float area;
float circumference;
};
circleData circle;
Which of the following statements is valid in C++?

1. cin >> circle.radius;


circle.area = 3.14 * radius * radius;
2. cin >> circle.radius;
circle.area = 3.14 * circle.radius * radius;
3. cin >> circle;
4. cin >> circle.radius;

QUESTION 51

Consider the following statements:


struct rectangleData
{
float length;
float width;
float area;
float perimeter;
};
rectangleData bigRect;
Which of the following statements is valid in C++?

1. cin >> bigRect.length >> width;


2. cout << bigRect.length;
3. cout << bigRect;
4. cout << length;

QUESTION 52

36
Consider the following statements:
struct supplierType
{
string name;
int supplierID;
};
struct applianceType
{
supplierType supplier;
string modelNo;
float cost;
};
applianceType applianceList[25];

Which of the following best describes applianceList?

1. It is a multidimensional array.
2. It is a struct.
3. It is an array of structs.
4. It is a struct of arrays.

QUESTION 53

Consider the following statements:


struct supplierType
{
string name;
int supplierID;
};
struct applianceType
{
supplierType supplier;
string modelNo;
float cost;
};
applianceType applianceList[25];
Which of the following statements correctly initializes the cost of each appliance to 0?

1. applianceList.cost = 0;
2. applianceList.cost[25] = 0;
3. for (int j = 1; j < 25; j++)
applianceList.cost[j] = 0;

4. for (int j = 0; j < 25; j++)


applianceList.cost[j] = 0;

QUESTION 54

What is the output of this program?


#include <iostream>
#include <string>
using namespace std;
struct student
{
int num;
char name[25];
};
int main()
37
{
student stu;
stu.num = 123;
strcpy(stu.name, "John");
cout << stu.num << endl;
cout << stu.name << endl;
return 0;
}

1. 123

John
2. John

John
3. 123

123
4. compile time error

QUESTION 55

What is the output of this program?


#include <iostream>
using namespace std;
struct Time {
int hours;
int minutes;
int seconds;
};
int toSeconds(Time now)
{
return 3600 * now.hours + 60 * now.minutes + now.seconds;
}
int main()
{
Time t;
t.hours = 5;
t.minutes = 30;
t.seconds = 45;
cout << "Total seconds: " << toSeconds(t) << endl;
return 0;
}

1. 19845

2. 20000

3. 15000

4. 19844

QUESTION 56

What is the output of this program?


#include <iostream>
using namespace std;
struct ShoeType
38
{
char style;
float price;
};
int main()
{
ShoeType shoe1, shoe2;
shoe1.style = 'Adidas';
shoe1.price = 9.99;
cout << shoe1.style << " R "<< shoe1.price;
shoe2 = shoe1;
shoe2.price = shoe2.price / 9;
cout << shoe2.style << " R "<< shoe2.price;
return 0;
}

1. Adidas R 9.99
Adidas R 1.11
2. Adidas R 9.99
Adidas R 9.11
3. Adidas R 9.99
Adidas R 11.11
4. Adidas R 11.99
Adidas R 9.11

QUESTION 56

Comment on the output of this C++ code?


#include <iostream>
struct temp
{
int a;
int b;
int c;
};
int main()
{
struct temp p[] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
return 0;
}

1. No Compile time error, generates an array of structure of size 3


2. No Compile time error, generates an array of structure of size 9
3. Compile time error, illegal declaration of a multidimensional array
4. Compile time error, illegal assignment to members of structure

QUESTION 57

Consider the following array declaration


int sales[5] = {10000, 12000, 900, 500, 20000};
The statement sales[3] = sales[3] + 10; will replace the number _____

1. 500 with 10
2. 500 with 510
3. 900 with 10
4. 900 with 910

QUESTION 58

39
Consider the following array declaration
int sales[5] = {10000, 12000, 900, 500, 20000};
The statement sales[4] = sales[4-2]; will replace the number _____

1. 20000 with 900


2. 20000 with 19998
3. 500 with 12000
4. 500 with 498

QUESTION 59

Consider the following array declaration


int sales[5] = {10000, 12000, 900, 500, 20000};
Which of the following if-statements verifies that the array subscript stored in the x variable is valid for the sales
array?

1. if (sales[x] >= 0 && sales[x] < 4)


2. if (sales[x] >= 0 && sales[x] <= 4)
3. if (x >= 0 && x < 4)
4. if (x >= 0 && x <+ 4)

QUESTION 60

Consider the following array declaration


int sales[5] = {10000, 12000, 900, 500, 20000};
Which of the following will correctly add the number 100 to each variable in the sales array? The x variable is
declared as int x = 0;

1. while (x <= 4)

x+=100;
2. while (x <= 4)

{
sales = sales + 100;
x+=1;
}
3. while (sales < 5)

{
sales[x] += 100;
}
4. while (x <= 4)

{
sales[x] += 100;
x+=1;
}

End of Assignment 2

40
8.8 Assignment 3
SUBMISSION: Electronically via myUnisa
Please note that we automatically give four days extension for this aassignment. It will be
to your own advantage to check after a few days whether the assignment has been registered
on the system. If you have not completed the assignment by the extension date, submit
whatever you have completed – you will get marks for everything that you have done.
If myUnisa is off-line when you want to submit the assignment, you need not contact us, because
we will be aware of it. Simply submit it as soon as myUnisa is available again.

DUE DATE 31 August 2021

UNIQUE NUMBER 841712

EXTENSION No extension

TUTORIAL MATTER Study Guide, Lessons 1 – 30

CONTRIBUTION WEIGHT TO 30%


SEMESTER MARK
QUESTIONS Practical exercises

IS YOUR SOFTWARE INSTALLED?


If you struggle to install the software, please contact your e-tutor.

Introduction 
 
You are required to write a program that simulates a flight booking system.  
 
A sample program execution is provided at the end of the document, to help you visualize and understand what the program 
should do. You should use the same input as the sample program, for the screenshots that you submit with your assignment.  
The flight route is from Johannesburg to Cape Town with the travel duration fixed at 2 ½  hours.  
o Departure and arrival locations remain the same. 
o Departure is always from Johannesburg and destination is always Cape Town. 
The departure and arrival times are: 
Option  Departure Time  Arrival Time
1  7:00  9:30
2  9:00  11:30
3  11:00  13:30
4  13:00  15:30
5  15:00  17:30
 
The seating arrangement is six seats in a row, three on the left side and three on the right side of the plane with a walkway 
(passage) in between. See the image of the setup below. 

41
  
(image source: http://travelgurureviews.com/kulula‐com‐reviews/airline‐reviews/ ) 
 
o The total number of seats in the flight is 50. 
o There are two classes of travel: First Class and Economy class.  
o The front four rows are considered as ‘First Class’ and all other rows to the back are ‘Economy Class’. 
o The cost for economy class is fixed at R 1 600.00.  
o The first class travel ticket is 20% more costly than the economy class. 
 
Questions 
You are required to do the following. (See the sample output screenshots for clarification).  
Write a program that will do the following: 
1. Prompt (ask) the user to enter his/her full name. 

 
2. Then display a menu showing the available times for the flight.  
 The user can choose a preferred departure time (option 1 ‐5).  
 The option selected should be validated for 1‐5.  

42
Validation for time option
chosen

 
3. If the user has entered a valid option, the seating arrangement for that particular flight time should be displayed to 
the user for the user to choose a seat.  

 
 If any seats have already been booked for that time, the booked seats should be indicated and displayed using “**”.  
 The user can then choose a suitable seat number that is available.  
 The seat number should be validated to see if it has already been booked.  
 In other words, if the user enters a seat number that is already booked, display a user‐friendly message 
and give the option to enter the seat number again. 
 

43
Booked seats indicated with “**”

 
4. Once the user has successfully chosen an available seat, a Flight booking ticket should be displayed on the screen.  
 Check the sample screenshot for the details that need to be displayed on the ticket. 

 
5. The program should prompt (ask) the user if they would like to make additional bookings?  
 Then the program should be able to repeat for more than one booking with various flight times.  
 The check for ‘y’ or ‘n’ at the “Do you want to continue(Y/N)?” prompt should be case‐insensitive. In other 
words, both ‘Y’ and ‘y’ should be accepted or both ‘N’ and ‘n’ should be accepted. 

 
6. When the user has finished all the booking and chosen ‘N’ or ‘n’ at the “Do you want to continue(Y/N)?” prompt, 
the program should display the total number of bookings made for each flight time, just before exiting. 

44
The program should display the total
bookings for each time, before exiting.

 
Submit the full program code and output screenshots. Include screenshots in your submission showing: 
 the program repeating; 
 input validations; 
 booking for different flight times.  
You are required to define and use functions to do the following: 
 Display the menu for flight times, accept the user option and validate the user option.  
o Call the function to validate the menu option from here. 
 
 Validate the menu option for flight times.  
 
 Display the seating arrangement (You might have to use two different functions for seat display).  
o  ie. before any booking has been made, you have one seating arrangement with all the seats available. 
After seats are booked, you have to display the booked seats with “**”).  
 
 Validate the availability of the chosen seat (to check if the seat has been already booked or not). 
o You DO NOT have to do validation for an invalid entry like Z3. We assume that the user enters a valid seat 
number that is displayed on the screen. You only need to check if it has been already booked or not. 
 
 Calculate the ticket price.(You are allowed to use a global named constant for the price of economy class, however, 
wherever you have to display the cost of ticket, you need to use this function to determine the price of the ticket. 
o  For instance, when you show the amount in the ticket that is displayed as output for each booking made. 
 
 Display the ticket, as shown in the sample output, for each booking. The function used to calculate ticket price can 
be called from this function. 
DO NOT use global variables. Except that you are only allowed to use global named constants for the following: 
o Cost of economy class ticket. 
o An array for storing departure times and arrival times. 
o For the size of any other arrays you might use. 
DO NOT use classes to write this program (you should be able to write this program with the help of other data structures 
that you have learnt). 
 
Additional information/ Hints: 
 
o You need to store the details of a particular booking, because you have to display the booked seats in the 
seating arrangement with “**”, when the program repeats.  
o Therefore, you need to think in the direction of storing the details of one booking which are of different 
data types, in one place.  
o  Again, if you are making more than one booking, then you have to store the details of various bookings in 
an array. Apply what you have learnt and use appropriate data types and data structures. 
o If you want to display the seat number as a combination of letter and number as in A1, A2 etc, then you 
can use the to_string() function to convert the integer to string and concatenate. For example: 

45
char row = 'A';
int col = 1;
string sNo = “”;
sNo += row;
sNo += to_string(col);
   
 
Sample Program  output (from one execution of the program without exiting): 

Validation for time option chosen 

46
Ticket display for a booking

Seats booked should be indicated with


“**”

47
Two seats booked for 7:00
am flight

   
A1 was already booked for 7:00
am flight. So display an
appropriate message that the seat
has already been taken.

48
 

A different flight time


chosen, and a
corresponding display.
No bookings were made
for this time, so all seats
available.

The program should display the total


bookings for each time, before exiting.

 
 
 
49
                        [TOTAL: 100 Marks] 
 
 
 
 
Assignment 2 ‐ Evaluation rubric: 
 
Program features  Marks
(Total 100) 

Use of appropriate header files    2 

Demonstration of the use of named constants 2 
 
Use of an appropriate data structure (this might vary depending on the logic) 5 

Function to validate flight time option chosen by the user 4 
 

Function to validate booked seats ‐ (2 marks for the header, 4 for the logic) 6 
 
Function to display time options. This function displays the menu for flight times, reads the  9 
time option from the user and validates the option within this function. 
‐ 2 marks for header 
‐ 4 marks for using a loop on the two‐dimensional array for flight times and displaying 
the menu. If the menu is displayed without the use of a loop, reduce 2 marks 
‐ 2 marks for the validation loop, to validate the option entered by the user 
‐ 1 mark for a user friendly message , if the option is wrong 
 
Note:‐ the function to validate flight time option should be called from this function to 
validate the option entered by the user. 
 
Function to display seats for any flight time for the first time(ie., with all seats available)   10 
‐ 2 marks for showing the headings for ‘First Class’ and ‘Economy Class’ correctly in the 
seat display 
‐ 2 marks for showing the ticket price against the headings of the travel class 
‐ 6 marks for a concise, sensible logic that uses control structures to display a neat 
seating arrangement. In other words, we do not expect to see numerous cout 
statements repeated for the seat display. 
 
Function to display seats for any flight time after some bookings have been made (ie., seats  10  
booked should be indicated with “**”)  
‐ 2 marks for the display 
‐ 3 marks for calling the validation function to validate seats 
‐ 5 marks for the logic to display the seating arrangement, with seats booked marked  
with ** 
 
Note:‐ the function to validate seat can be called here on each seat to check if it has been 
already booked or not. If a seat is booked mark it with “**” otherwise display the seat no. 
 
Function to determine ticket cost based on the class of travel(first class or economy class)   5 
50
‐ The price of first class ticket should be calculated as 20 % more than the economy 
class. Note that you are allowed to store the price of the economy class as a global 
constant. 
‐ If a static value of R1920(ie., without showing the calculation) is used for first class 
ticket, then reduce 2 marks 
 
Function to display ticket  8  
‐ 1 mark for the function header 
‐ 2 marks for the logic to get the travel class(first or economy) correct based on the 
seat chosen 
‐ 2 marks for calling the function to calculate ticket price. 
‐ 3 marks for displaying all the information on the ticket 
 
The main()  16  
‐ For valid variable declarations – 2 marks 
‐ For reading full name – 1 mark 
‐ For the validation loop to check if a seat no. entered by the user is already taken or 
not, and if taken display an appropriate message – 2 marks (Note:‐ the function to 
validate seat should be called here). 
‐ For repeating the program for various bookings, acceptance of case‐insensitive 
response at the ‘continue’ prompt – 3 marks 
‐ Logic for displaying the counts at the end, once the program exits – 3 marks 
‐ For the various function calls and rest of the logic – 5 marks 
 
Output formatting (for eg: neat display of the travel ticket, seat arrangement etc)  3 
 
YOU WILL GET THE FOLLOWING MARKS FOR THE CORRECT USE OF AT LEAST ONE OF EACH: 
 
‐ two‐dimensional array – 2 marks 20 
‐  one‐dimensional array – 2 marks 
‐ void function with reference parameter(s) – 2 marks 
‐ value‐returning function – 2 marks 
‐ void function with value  parameter(s) – 2 marks 
‐  ‘if’ construct for decision‐making – 2 marks 
‐ switch construct for decision‐making – 2 marks 
‐ while loop construct – 1 mark 
‐ do…while loop construct – 2 marks 
‐ for loop construct – 2 marks 
‐ use of array as function argument ‐ 1 
 
   
 

End of Assignment 3

51
8.9 Assignment 4

SUBMISSION: Electronically via myUnisa


Please note that we automatically give four days extension for this aassignment. It will be
to your own advantage to check after a few days whether the assignment has been registered
on the system. If you have not completed the assignment by the extension date, submit
whatever you have completed – you will get marks for everything that you have done.
If myUnisa is off-line when you want to submit the assignment, you need not contact us, because
we will be aware of it. Simply submit it as soon as myUnisa is available again.

DUE DATE 04 October 2021

UNIQUE NUMBER 862799

EXTENSION There is NO extension for this assignment.

TUTORIAL MATTER Study Guide, Lessons 24 –

CONTRIBUTION WEIGHT TO 20%


SEMESTER MARK
 

                                                                                                                         [85 Marks] 

QUESTION 1: WHILE LOOP and SWITCH 
An events ticket booking System prompts the user to make a choice as well as the number of tickets required. It 
then displays the total cost of the order. The menu options and cost per ticket is as follows: 

1 Exclusive VIP area A : R3 000.00


2 VIP area B : R2 000.00
3 Elevated area :R1200.00
4 General area R600.
0 QUIT

QUESTION 1a 
A valid selection must be between 0 and 4. Enter the program below and complete the while loop. Name the 
program question1.cpp, compile and run it. 

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
// Fill in the code to define an integer variable called selection

cout << "Please enter the choice of ticket "


<< "(a number from 1 to 4 or 0 to quit) " << endl;
cout << "Ticket Menu " << endl << endl;
cout << "1: Exclusive VIP area A " << endl;
52
cout << "2: VIP area B " << endl;
cout << "3: Elevated area " << endl;
cout << "4: General area R600 " << endl;
cout << "0: QUIT " << endl <<endl << endl;
cin >> selection ;
while (…………………)//complete the condition

{
cout << “Invalid choice – Please re-enter “;
cin >> selection;
}
cout << “You have selected option number “ << selection;
return 0;
}

QUESTION 1b                                                                                                                                                      (10 Marks) 

Modify question1.cpp by adding the code to calculate the cost per order. Make use of a switchstatement. 

cout << "You have selected option number "“ <<;


cout << "How many tickets would you like?" << endl;
// Fill in the code to read in number
// Fill in the code to begin a switch statement
// that is controlled by selection
{
case 1: cost = number * 3000;
cout << "The total cost is R " << cost << endl;
break;
// Fill in the code for the case VIP area B ( R2000.00 each)
// Fill in the code for the case Elevated area (R1200.00 each)
// Fill in the code for the case General area (R600.00 each)

case 0: cout << " Please come again" << endl;


break;
default:
cout << “Invalid selection”
cout << " Try again please" << endl;
}
Submit: question1.cpp + output

QUESTION 2: FOR LOOP 
QUESTION 2a 
Include the for loop below in a small program named question2.cpp and complete the program. The loop should 
be executed 10 times. Do not change the for loop below. Compile and run your program to see for yourself that 
it works. You do not have to submit this program and output. 
for (int i = 1; i <= n; i++)
if (i < 5 && i != 2)
cout << 'X';

Now convert the for loop into a while loop and add any variable initializations that you think are necessary. 


Name the program question2a.cpp, compile and run your program.                                                      (5 marks) 
 
QUESTION 2b 
The following code is supposed to calculate the sum of the numbers 2 through 5. That is, it should calculate the 
value of 2 + 3 + 4 + 5, which is 14. However, there is a logical error in the code. Explain what the output of 
53
the code below will be. Then write a small program named question2b.cpp, include the code below and make the 
necessary changes to fix the code so that it displays what it is intended to display. Ensure that your program works 
correctly. Only submit the program, not the output.                                                                                  (5 marks) 

Hint: Use variable diagrams to trace the program to help you find the logical error. 
int next = 2, sum = 1;
while (next <= 5)
{
next++;
sum = sum + next;
}
cout << "The sum of 2 through 5 is " << sum << endl;
Submit: question2a.cpp 
question2b.cpp 

QUESTION 3: NESTED LOOPS 
A lecturer requires information regarding the average time a student spent programming each day over a three 
day long weekend. Copy the code below into CodeBlocks, save it as question3.cpp, compile and run it. 
// This program finds the average time spent programming by a student
// each day over a three day period.
#include <iostream>
using namespace std;
int main()
{
int numStudents;
float numHours, total, average;
int student,day = 0; // these are the counters for the loops
cout << "This program will find the average number of hours a day"
<< " that a student spent programming over a long weekend\n\n";
cout << "How many students are there?" << endl << endl;
cin >> numStudents;
for( student = 1; student <= numStudents; student++)
{
total = 0;
for(day = 1; day <= 3; day++)
{
cout << "Please enter the number of hours worked by student"
<< student <<" on day " << day << "." << endl;
cin >> numHours;
total = total + numHours;
}
average = total / 3;

cout << endl;


cout << "The average number of hours per day spent programming "
<< "by student " << student << " is " << average
<< endl << endl << endl;
}
return 0;
}

54
QUESTION 3a 
The outer loop controls the number of students. Note that the inner loop of this program is always executed 
exactly three times, once for each day of the long weekend. Modify the code so that the inner loop iterates n
times, where n is a positive integer that the user inputs. Thus, the users decide how many days to consider just as 
they choose how many students to consider. 
A sample run: 
This program will find the average number of hours a day that a student spent
programming over a long weekend;
How many students are there?
2
Enter the number of days in the long weekend
2
Please enter the number of hours worked by student 1 on day 1
4
Please enter the number of hours worked by student 1 on day 2
6
The average number of hours per day spent programming by student 1 is 5
Please enter the number of hours worked by student 2 on day 1
9
Please enter the number of hours worked by student 2 on day 2
13
The average number of hours per day spent programming by student 2 is 11

QUESTION 3b 
Modify question3.cpp so that it also finds the average number of hours per day that a given student studies biology 
as well as programming. For each given student include two prompts, one for each subject. Have the program 
display which subject the student, on average, spend the most time on. 

Submit: question3.cpp + output                                                                                                                       (15 marks) 

QUESTION 4: VOID FUNCTIONS 

A function named printTabs (with no parameters) produces a table as the numbers 1 to 10, their squares and 
their cubes as shown below. 

NUMBER SQUARE CUBE


1 1 1
2 4 8
3 9 27
4 16 36
5 25 125
6 36 216
7 49 343
8 64 512
9 81 729
10 100 1000

55
QUESTION 4a 
Write the function printTabs. Include the function in a working program named question4.cpp and call
function printTabs from main().

QUESTION 4b 
Modify program question4.cpp by adding a function selTabs to accept the starting value of the table, the 
number of values to be displayed, and the increment between the values. If the increment is not explicitly sent, 
the function should use a default value of 1. A call to selTabs(6,5,2)should produce a table of five lines, the 
first line starting with number 6 and each succeeding number increasing by 2. 

A sample run: 
Enter the starting value of the table
6

Enter the number of values to be displayed


5

Enter the increment between the values


2

NUMBER SQUARE CUBE


6 36 216
8 46 512
10 100 1000
12 144 729
14 100 1000

Submit: question4.cpp + output                                                                                                                       (15 marks) 

QUESTION 5: FUNCTIONS WITH DIFFERENT RETURN TYPES AND PARAMETERS 

QUESTION 5a                                                                                                                                                      (10 marks) 

Write a program named question5a.cpp that will calculate and print pay slips. User inputs are the name of the 
employee, the number of hours worked and the hourly pay rate. You have to declare three functions. 
a) one for input; 
b) one to calculate the employee’s pay; and 
c) one to print the payslip. 

The input function has to input the name of the employee, the number of hours worked and the hourly pay rate 
into the variables theEmployee, theHoursWorked and thePayRate. The variable employee is a string 
and the other two variables are of type float. As the values of theEmployee, theHoursWorked and 
thePayRate will be changed in this function, reference parameters need to be used.

56
COS1511/101/3/2021

The calculation function will receive two parameters that represent the number of hours worked and the hourly pay 
rate, do the calculation and return the pay for the employee. An employee, who has worked more than 40 hours, is 
paid 1.5 times the hourly pay rate for each hour of overtime. As the parameters are not changed in the function, they 
should be value parameters. The function should return a float value which represents the pay. The output function 
has to display the name of the employee, the number of hours worked, the number of overtime hours and the hourly 
pay rate entered by the user as well as the employee’s pay. For example: 
Pay slip for Harry Matsipe

Hours worked: 43.5 hours


Overtime hours: 3.5
Hourly pay rate: R125.35
Pay: R5672.09

The main function includes a for loop that allows the user to repeat the calculation of a pay slip for five employees. We 
give the main function below. You must submit the three functions you have developed as well as output for repeating 
the loop five times with the following input data: 

Harry Matsipe 43.5 125.35 
Ellen Malan 39.4 112.75 
Joey Rashdien 40 120.45 
Mpho Bopape 41.2 123.60 
Veli Singh 39.7 135.30 

QUESTION 5b                                                                                                                                                      (12 marks)  
 
NuMetro has a special on movies for all members of the public but special discounts for students and pensioners. If 
pensioners or students buy a movie ticket they receive 10% if they buy a movie and popcorns, they receive 20% 
discount. Other customers only receive a discount when they buy a movie ticket and popcorn; there is no discount for 
just a movie ticket alone.  
Write a program named question5b.cpp that will consist of two functions. The program must prompt the user for type of 
customer (‘p’ for pensioner, ‘s’ for student, ‘o’ for other). It must then call the relevant function according to that entry. 
The first function must receive the customer type and calculates discount for pensioners and students. The second 
function calculates the discount for customers that are not pensioners or students. 

QUESTION 5c                                                                                                                                                       (13 marks) 

Write a program named question6c.cpp that demonstrates the use of the following functions. A C++ function named 
getName()prompts the user for two string values; first name and last name and return a combination of the two as 
one value. The second function getHours()calculate employee’s weekly pay, it must receive one argument, 
fullName, a stringvariable and a floatvalue for the rate. It must then prompt the user for hours worked for each 
day of the week, i.e. Monday – Friday and calculates the weekly pay. Employees who have worked more than 40 hours 
that week will receive a bonus of 10% and those who have worked less than 40 hour will receive 10% less pay for that 
week. 

Submit: Program question5a.cpp + output 
Program question5b.cpp + output 
Program question5c.cpp + output 

End of Assignment 4

59
COS1511/101/3/2021

9 The examination
The examination mark will be converted to a mark out of 80 to which your semester mark out of
20 will be added to get your final percentage for the examination. Note that the semester mark will
not be taken into consideration if you are writing the supplementary examination.

10 FREQUENTLY ASKED QUESTIONS


See Frequently Asked Questions in the Frequently Asked Questions section for COS1511 on
myUnisa. Consult the Study @ Unisa brochure which contains an A-Z guide of the most
relevant study information.
Question Title:
What can I do if I have not received any study material?
Answer:
The physical copies of the material are distributed by the University's dispatch department and this
can get delayed owing to many unexpected events that might occur during the year.
The lecturers have made the soft copies available on MyUnisa. In the "Official Study Material"
section as well as the "Additional Resources" section.
The software is available in the "Additional Resources" section as well as on the School
of
Computing’s Osprey server: http://osprey.unisa.ac.za/.
The study guide should help introduce you to C++ programming and the tutorial letter has the
module schedule, including assignment due dates and assignment questions.

Question Title:
Where are the discussion forums?
Answer:
The discussion forums are your tutor groups and activated by your tutors. Please note that you will
be allocated an e-tutor as soon as the administration of e-tutors have been completed. You will receive
an email on your myLife account regarding the allocation. We as lecturers are not involved in the
process. As soon as you are allocated an e-tutor, you can access the myUnisa e-tutor site where a
discussion forum will be available.

11 SOURCES CONSULTED
Module study guide and module Form 1 for outcomes.

12 IN CLOSING
Do not hesitate to contact us by email if you are experiencing problems with the content of this
tutorial letter or with any academic aspect of the module.
59
COS1511/101/3/2021
We wish you a fascinating and satisfying journey through the learning material and trust that you
will complete the module successfully.
Enjoy the journey!
COS1511 Lecturer
SCHOOL OF COMPUTING

©
UNISA 2021

59

You might also like