2
3
4
5
6
7
to do the test.
You will get 0 (zero) for any answer which contains information irrelevant to the corresponding question.
Question 1 (3 points): Review the following class and find (at least) 6 issues in the code (i.e.,coding practice, compile errors, potential logical issues, etc.) (Use question 1 template)
public class AverageCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
ArrayList<Double> NUMBERS = new ArrayList<>();int avg;
System.out.print("Enter the number of values to calculate the average: ");
8
int NumValues = scanner.nextInt();
9
10
double sum = 0;
11
for (int i=0; i NumValues; i++) {
12
System.out.print("Enter value #"+i+": ");
13
double value scanner.nextDouble();
14
15
16
NUMBERS.add(value);
sum += value;
}
17
18
if (NumValues != 0) {
19
double average sum / NumValues;
20
System.out.println("The average is:average);
21
} else {
22
System.out.println("No values provided. Cannot calculate the average.");
23
}
24
25
}
26
}
Zoom
+ 100%
Question 2 (3 points): Assuming you are assigned to conduct the component test for the method below, please design and create the minimum component test cases (Unit Test case) needed to
achieve 100% statement coverage and 100% decision coverage. (Use question 2 template).
The countCharacters method that counts the number of uppercase letters, lowercase letters,
Close