Programming 621 Assignment
Programming 621 Assignment
ASSIGNMENT INSTRUCTIONS
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.
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.
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.
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 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.
Test the above operations by writing a complete program using single inheritance. Make necessary assumptions
for constructors, member functions, and data validation where required.
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.
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
• Initial balance
• Number of withdrawals
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.