100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
COS 1512 ASSIGNMENT 3 2023. R54,16   Add to cart

Exam (elaborations)

COS 1512 ASSIGNMENT 3 2023.

 2 views  0 purchase

COS 1512 ASSIGNMENT 3 2023. COS 1512 ASSIGNMENT 3 2023.

Preview 2 out of 7  pages

  • August 16, 2023
  • 7
  • 2023/2024
  • Exam (elaborations)
  • Questions & answers
All documents for this subject (1)
avatar-seller
tutorburton4
COS 1512
ASSIGNMENT 3 2023.


DUE DATE: 21 August 2023
CUT-OFF DATE: 24 August 2023

TUTORIAL MATTER:
Chapters 10, 11, 12 and 15 of the Study
Guide (Appendix D)

Chapters 10, 11, 12 (excluding “Creating a
Namespace”)
Appendices 7 and 8 in Savitch
None
EXTENTION:

WEIGHT: 40%



Question 1
Consider the following structure used to keep employee records:
struct Employee
{
string firstName;
string lastName;
float salary;
}


Turn the employee record into a class type rather than a structure type. The employee
record class should have private member variables for all the data. Include public
member functions for each of the following:
• a default constructor that sets the employee‘s first name and last name to a blank
string, and his annual salary to 0;
• an overloaded constructor that sets the member variables to specified values;
• member functions to set each of the member variables to a value given as an
argument to the function (i.e. mutators);
• member functions to retrieve the data from each of the member variables (i.e
accessors);

Embed your class definition in a test program. The test program should create two
Employee objects and display each object’s annual salary. Use the overloaded
constructor to initialise one of the Employee records as Joe Soap with an annual salary
of R145600.00. Obtain the following input values for the other Employee record from
the keyboard:
Joanne Soape
R154460.66

, Now give each employee a 10% raise and display each Employee object’s annual
salary again.


Quesion 2
Design and implement a C++ class called Module that handles information regarding
your assignments for a specific module. Think of all the things you would want to do
with such a class and write corresponding member functions for your Module class.
Your class declaration should be well-documented so that users will know how to use
it.
At a minimum your class Module should contain information on the module code, the
module name, the marks for assignments, the year mark and the final mark.
Test your class in a small program where you instantiate an object of the class,
initialize the member variables that represents the assignment marks, calculate a year
mark and display the year mark.


Quesion 3
Implement your class Module from question 2, as an abstract data datatype (ADT)
using separate compilation, so that separate files are used for the interface and
implementation.
Write a main program that does the following:

• Declare an array of all your modules. The elements of the array must be of
objects of the class Module.
• Initialise the array with the modules you are registered for. Obtain the module
codes, names of modules and assignment marks from the user. Initialise each
module with the assignment marks you have obtained for the module (or would
like to obtain for the module).
• Determine your semester mark for each module: the first assignment
contributes 30% and the second assignment 70%. Display the semester marks.
• Adjust the marks for Assignment 2 for COS1512 with +5%.
• Determine your semester mark for COS1512 again to see what effect the
update had.
• Display an updated list of your semester marks for all the modules you are
registered for.


Enrichment exercise:
Adapt the application program to use a vector instead of an array. It should not
be necessary to change the class interface or implementation file in any way.

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through EFT, credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying this summary from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller tutorburton4. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy this summary for R54,16. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

78834 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy summaries for 14 years now

Start selling
R54,16
  • (0)
  Buy now