0% found this document useful (0 votes)
2 views3 pages

Programming 621 Assignment

The document outlines assignment instructions for a programming course, detailing requirements for formatting, submission, and originality declaration. It includes three programming questions that involve dynamic memory allocation, resource management systems, and a bank charge calculation program. Each question specifies tasks related to C++ programming, including the use of classes, file handling, and mathematical computations.

Uploaded by

Eva
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Programming 621 Assignment

The document outlines assignment instructions for a programming course, detailing requirements for formatting, submission, and originality declaration. It includes three programming questions that involve dynamic memory allocation, resource management systems, and a bank charge calculation program. Each question specifies tasks related to C++ programming, including the use of classes, file handling, and mathematical computations.

Uploaded by

Eva
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Programming 621

Name and Surname:

Student ITS No:

Qualification: Year of Study: Semester:

Assignment due date: Date submitted:

QUESTION EXAMINER MARKS MODERATOR MARKS REMARKS

ASSIGNMENT INSTRUCTIONS

Please tick each box to confirm completion.


Use Times New Roman font, size 12, with 1.5 line spacing throughout the document.
Apply Harvard Referencing Style for all citations and references.

For essay-style assignments, please include the following sections:


Table of Contents
Introduction
Main Body (with relevant subheadings)
Conclusion
References

Submit the assignment in PDF format on Moodle.


Use the specified cover page provided.
Include a signed declaration of originality.

DECLARATION OF ORIGINALITY:
I hereby declare that this assignment is my own work and has not been copied from any other source except where due
acknowledgment is made. I affirm that all sources used have been properly cited and that this submission complies with
the institution’s policies on academic integrity and plagiarism.

Student Signature: Date:

Richfield Graduate Institute of Technology (Pty) Ltd is registered with the Department of Higher Education & Training as a Private Higher Education Institution under the Higher
Education Act, 1997, Registration Certificate No. 2000/HE07/008.
Question One (20 Marks)

Write a program that dynamically allocates an array of 𝑛 mathematical expressions. The expressions
follow the form: 𝑓(𝑥)=𝐴𝑥2+𝐵𝑠𝑖𝑛(𝐶𝑥)+𝐷 where 𝐴,𝐵,𝐶,𝐷 are randomly generated integers between −50
and 50 and 𝑥 takes values form −10 to a maximum determined by 𝑛.
Your program must:
1. Allocate memory dynamically and populate the array using pointer arithmetic.
2. Compute statistics (mean, standard deviation, sum of positive values, sum of negative values)
without using array indexing.
3. Apply transformations using function pointers, with options:
- Square root (valid for positive values)
- Logarithm (valid for positive values)
- Inverse (valid for nonzero values)
4. Compute the sum of all elements recursively, using only pointer arithmetic.
5. Swap two dynamically allocated arrays using a pointer-to-pointer function.
Ensure proper memory management by deallocating all allocated memory at the end of execution.
Avoid using array indexing (arr[i]) anywhere in the program.

Question 2 (25 Marks)

Write a program that simulates a Disaster Relief Resource Management System for tracking essential resources
such as food, water, and medical kits. The system should store resource information (resourceID, resourceName,
quantity, unitPrice, location) in a text file and perform the following operations:
- Adding new resources
- Updating existing resources
- Deleting resources
- Searching for specific resources
The program must read the data from the text file and store it in an array. Users should be able to input valid
data, which will then be saved back to the file after each operation.

Question 3 (20 Marks)

A library wants to implement a management system for its book collection. You are requested to develop such a
program in which you must:

• Declare the base class Book to store basic book information with auto-generated IDs.

• Use the function called getBookInfo() to input book details (title, author, publisher, ISBN).

• Declare the derived class LibraryBook that inherits from Book.

• Declare and define the function getStatus() to track book availability and borrowing history.

• Define the function calculateFine() to determine overdue charges when books are returned late.

Richfield Graduate Institute of Technology (Pty) Ltd is registered with the Department of Higher Education & Training as a Private Higher Education Institution under the Higher
Education Act, 1997, Registration Certificate No. 2000/HE07/008.
• Create an array to store exactly 10 books.

• Call the functions getBookInfo(), getStatus(), and calculateFine() for each book as needed.

• Implement a menu-driven interface to manage all operations.

Test the above operations by writing a complete program using single inheritance. Make necessary assumptions
for constructors, member functions, and data validation where required.

Question 3 (25 Marks)

Write a C++ program to calculate the monthly bank charges for Capitec Bank savings account holder based on
their withdrawal details. The program should consider various factors specific to Capitec Bank, such as the
monthly admin fee, withdrawal charges, and overdraft penalties. The program should prompt the user to input
the account holder's name, current balance, number of withdrawals made, and withdrawal amounts for the
month.

Calculate the total charges using the formula:

total_charges = monthly_admin_fee + (withdrawals * withdrawal_charge) + overdraft_penalty, where


overdraft_penalty is R375 if the balance falls below R0.00.

For Capitec savings accounts, the withdrawal charge is R22.50 per withdrawal after the first four free withdrawals,
and the monthly admin fee is R5.00.

Display the calculated charges for the account holder in a detailed format showing

• Account holder's name

• Initial balance

• Number of withdrawals

• Breakdown of charges (admin fee, withdrawal charges, penalties)

• Final balance after deducting all charges

NB: The program should also validate that withdrawal amounts do not exceed the available balance unless the
account holder has overdraft facility.

Richfield Graduate Institute of Technology (Pty) Ltd is registered with the Department of Higher Education & Training as a Private Higher Education Institution under the Higher
Education Act, 1997, Registration Certificate No. 2000/HE07/008.

You might also like