PROGRAMMING 511
[Link]
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 1 (15 marks)
1.1. What is the difference between a compiler and an interpreter? (6 marks)
1.2. What is the difference between low- and high-level programming languages?
Provide an example of each. (5 marks)
1.3. Convert 43 to a binary number. (Show ALL working) (4 marks)
Question 2 (15 marks)
To approximate the natural logarithm ln(1 + 𝓍), we can use the following formula:
𝓍2 𝓍3 𝓍4
ln(1 + 𝓍) = 𝓍 − + + +⋯
2 3 4
This series works for the values of 𝓍 where −1 < 𝓍 < 1.
Write a program that performs the following:
- Ask the user to input 𝓍 and ensures −1 < 𝓍 < 1.
- Allow the user to specify a precision (e.g., 0.000001) or a maximum number of terms.
- Calculate the approximation, stopping when either:
• The change between the two steps is less than the precision, or
• The maximum number of terms is reached.
- Print each term, the running total, and the difference between the current and previous
totals.
- Provide a summary at the end, including:
• The final approximation of ln(1 + 𝓍),
• The exact value of ln(1 + 𝓍), using [Link].
• The number of terms used.
• The difference between your result and the exact value.
Question 3 (15 marks)
Create a program that uses nested for loops to print the pattern shown below:
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
* *
* *
* *
* *
* * * * * * *
Question 4 (15 marks)
A bank in your town updates its customers’ accounts at the end of each month. The bank offers
two types of accounts: savings and checking. Every customer must maintain a minimum balance.
If a customer’s balance falls below the minimum balance, there is a service charge of $10.00 for
savings accounts and $25.00 for checking accounts. If the balance at the end of the month is at
least the minimum balance, the account receives interest as follows:
• Savings accounts receive 4% interest.
• Checking accounts with balances of up to $5,000 more than the minimum balance
receives 3% interest; otherwise, the interest is 5%.
Write a program that reads a customer’s account number, account type, ‘s’ for savings, ‘c’ for
checking, minimum balance that the account should maintain, and current balance. The program
should then output the account number, account type, current balance, and an appropriate
message.
Question 5 (30 marks)
You need to create a program to manage a simple inventory system for a store. The program
should handle the following:
1. Each product has an ID, name, category, quantity, and price. This data is stored in a text file
called [Link]. If the file doesn't exist, it should be initialised with sample data.
2. The program should allow the user to perform the following operations:
• Add a new product.
• Update an existing product.
• Delete a product.
• Sort products by price.
• Filter products by category.
• Generate an inventory summary report (Displays all product details (ID, name, category,
quantity, price).
• Generate a category summary report (Summarises the number of products and the total
value per category.)
NB: The program should present a console menu for users to choose the operation they want to
perform.