Search for question
Question

QUESTION 4

Write a method called getNumbers. It takes in one parameter called FileName(string) and

returns an array of 10 integers. This method should open a file called FileName (You can

assume the file will be in the working directory of the program). It should read a number from

each line of the file and store it in the array in the next available cell.

Example file Numbers.txt:

2

5

8

10

20

17

This example would result in an array where cells 0 has a 2 in it, cell 1 has a 5 in it....cell 5 has

17 in it. Cells 6 to 9 of the array will have 0's in them. However, your code must work for a file

with any numbers in it.

If the file has more than 10 values in it, your method should throw an exception with the

message "Too many numbers."