Final answer:
The student is asked to develop two programs: one for listing unique words from a text file, and another to remove an array element at a specified index. Examples provided are in Python, including error handling for the second task.
Step-by-step explanation:
The question relates to programming, tasking the student to write programs in Java, C++, or Python for two different problems and to develop the logic using flowcharts or pseudocode. The first task involves writing a program that opens a text file, reads its contents, and displays a list of all the unique words found in the file using a set data structure. The second task is to write a method named removeAt that manipulates an array of integers, specifically removing an element at a specified index and handling errors related to index out-of-bound or empty array scenarios.
Example for Program 1 in Python:
def unique_words(filename):
with open(filename, 'r') as file:
words = set(file.read().split())
print("\\Unique words in file:", words)
unique_words('sample.txt')
Example for Program 2 in Python:
def removeAt(arr, length, index):
if 0 <= index < length:
arr.pop(index)
length -= 1
return arr
else:
return "Index out of range or array is empty"