Texts: Lab 06 Array & ArrayList
Complete ALL exercises.
Submission
Ex6a: Submit the project copied from Eclipse. [No grade given if NOT submit project]
Ex6b and Ex6c: the Java programs file. [NO grade given if submit txt file]
Ex6a
This exercise requires you to develop a program named temp_range_operator that implements the following operations:
1. Prompt the user to input the number of days for which temperatures need to be inputted.
2. Store the inputs in an array, and then output the following for the input days:
a. Maximum temperature of the input days
b. Minimum temperature of the input days
c. The average temperature of the input days
d. The number of days above the average temperature
e. The mode of the temperature of the input days (if mode is not found, e.g., if all days have different temperatures, the output will be a message 'NONE')
NOTE:
- This exercise requires you to design meaningful variable names.
- The interactions between the user and the program should resemble the following typical output, with the addition of your personal information to show that it is your own work.
- You need to identify all features that are not clearly specified in this lab question.
- You MUST use an array to store the temperatures, and use a Java for-each loop to calculate the maximum, minimum, average, and number of days above average. For inputting temperatures, you can optionally use a for-each loop or a for-loop.
How many days' temperatures? 3
Day 1's high temperature: 23.4
Day 2's high temperature: 33.2
Day 3's high temperature: 40.2
The maximum temperature of the given range is 40.2
The minimum temperature of the given range is 23.4
The average temperature of the given range is 32.3
The input range has 2 day(s) above the average temperature!
This sample is missing the output of the mode. You need to add this operation in this program.
Ex6b.
Write a program called matOps that will add and subtract TWO 4x4 2-D matrices. To test your program, you need to generate TWO 4x4 2-D matrices with random values of integers ranging from 1 to 100.
The program will be:
1. Display the generated 2-D matrices.
2. Display the outcome of the addition and subtraction of the matrices.
[You may need to study how to add and subtract 2-D matrices]
An example of adding two matrices:
[[4,8],[3,7]] + [[1,0],[5,2]] = [[4+1,8+0],[3+5,7+2]]
Ex6c
Write a program called breakParts that breaks a series of characters (stored in an ArrayList) into two parts based on a given break-point.
Examples:
a. Given the ArrayList of characters [a, b, c, d, e, f, g, h, i, j, k], and the break-point is e, the program breaks the given ArrayList into two parts: [a, b, c, d, e] and [f, g, h, i, j, k].
b. Given a list of characters [a, b, c, d, e, f, f, h, l, j, k] and the break-point is f, the program breaks the given ArrayList into two parts: [a, b, c, d, e, f] and [f, h, l, j, k]. (Broken based on the first match)
c. Given a list of characters [a, b, c, d, e, f, f, h, l, j, k], and the break-point is m, the program displays an empty list.
NOTE: For this program, the use of ArrayList is a MUST. You are also required to design the program's user interactions. Providing detailed comments on your work is essential.
End of Lab 6