Be sure you have read chapter 7.
Do the following programming problems. You will end up with at least one code file per problem. Submit your program source (and any other needed files) by sending mail to bmassing@cs.trinity.edu, with each file as an attachment. Please use a subject line that mentions the course and the assignment (e.g., ``csci 1320 homework 5'' or ``CS1 hw5''). You can develop your programs on any system that provides the needed functionality, but I will test them on one of the department's Linux machines, so you should probably make sure they work in that environment before turning them in.
So, each program should start by prompting the user for the number of elements in the array or list and the maximum value. It should then generate the array or list, and then prompt the user for a number to search for and call each of the different functions to count how many times the number to search for appears in the array or list. The four functions should all accomplish the same goal, but using different methods:
how many numbers?
20
maximum value?
10
the numbers:
0
9
4
2
8
2
3
10
2
6
0
8
10
6
8
10
10
2
5
9
number to search for?
10
count using recursion = 4
count using count = 4
count using filter = 4
count using map = 4
Hints:
Array.fill(10)(util.Random.nextInt(100))The same thing works with lists (replace Array with List).
array_or_list.foreach(println(_))
The program should prompt for the coefficients through and the value of the variable and then print the value of the above expression. It's probably simplest to first ask how many coefficients there will be, then ask for that many values (so you can use fill to get the values), and finally ask for the value of the variable . Sample execution (as usual, text in boldface is what you type and text in typewriter font is what the program prints):
how many coefficients?(Probably the program should allow entering doubles rather than integers; the example uses integers to make the answer easier to check.)
4
enter 4 coefficients, one per line
1
3
2
4
enter value for variable
100
value is 1030204.0
Hints:
More details about this hint on request, but think about it a bit first. Or you may have a different idea that you find more straightforward!