?
import javax.swing.*;class FindPoints{ public static void main(String[] args) { int[][] points =
{{10, 20, 30}, {20, 40, 60}, {40, 60, 80}}; String prompt; int class; int level; prompt = JOptionPane.showInputDialog(null, "Class: "); class = Integer.parseInt(prompt); prompt = JOptionPane.showInputDialog(null, "Level: "); level = Integer.parseInt(prompt);
JOption.showMessageDialog(null, "Your points: " + points[class][level]);
}
}
The above code depicts a two-dimensional array named points that refers to a Class and Level to determine a point value. If a user inputs a Class of 1 and a Level of 2, what point value will be displayed when the program executes? Explain how you arrived at your answer.
What will be an ideal response?
The point value will be 60.When working with the points array, the rows are numbered started with 0. Since there are three rows, they are rows 0, 1, and 2. The rows represent the Class. The columns also start with column 0, and in this case we have columns 0, 1, and 2. When the user enters a value of 1 for the class, the array is directed to row 1, which has the values 20, 40, and 60. When the user then enters a value of 2 for the Level, the array is directed to the third value in the row, which is 60. Therefore, the value of points[class][level] in the execution is 60.
You might also like to view...
To select noncontiguous rows, you:
A) click the header of the first row, then double-click the header of each additional row. B) click the header of the first row, then right-click the header of each additional row. C) click the header of the first row, press and hold Shift, and click the header of each additional row. D) click the header of the first row, press and hold Ctrl, and click the header of each additional row.
When formated as a date, the results of EDATE(Start_Date,3 ) if the contents of Start_Date is 10/30/2018 would be ________
A) 1/31/2019 B) 10/31/2018 C) 1/30/2019 D) 11/2/2018