Duration: 80 minutes
Instructions:
You need to know at least one programming language to perform reasonably well on certain exam questions.
Students are allowed to use IDEs such as NetBeans, IntelliJ IDEA, or similar software 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)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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: ");
int NumValues scanner.nextInt();
double sum 0;
for (int i=0; i< NumValues; i++) {
System.out.print("Enter value #"+i+": ");
double value scanner.nextDouble();
NUMBERS.add(value);
sum += value;
1
Zoom
+ 100%
Close