PS 8
PS 8
Problem Solving 8
Anıl Demirel
December 9, 2024
Instructions
This worksheet contains 8 problems covering topics discussed in Week 10 of
CMPE 261. You are encouraged to solve these problems independently. Use
Python, Java, or C++ as specified in each problem. Submit your solutions
as a single compressed folder containing the source code for each problem.
• Allocate memory dynamically for a list (or array) of integers of size 10.
• Print the contents of the list and free the memory (where applicable).
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
1
• Concatenate 100,000 strings using a naive approach.
Output Example:
Result: 50
2
Problem 5: Error Handling
Write a program that demonstrates error handling:
Enter a number: 0
Error: Division by zero is not allowed.
Thread 1: 1 2 3 4 5 6 7 8 9 10
Thread 2: 1 2 3 4 5 6 7 8 9 10
Thread 3: 1 2 3 4 5 6 7 8 9 10
• Calculate and display the top 5 countries with the highest cases per
million.
3
Problem 8: OOP Features Comparison
Write a program demonstrating polymorphism:
• Calculate and display the area for objects of both derived classes.
Rectangle Area: 20
Circle Area: 28.27