programming

An instructor wants to build a program to help him keep track of students’ grades. He’s assuming he won’t have more than 30 students and won’t have more than 2 exams from which he’ll calculate the average. How many arrays do you think he needs to use? What are some of the suggested names you can think of, and what might the code look like?

Answers

For this situation, the instructor will need two arrays: one to store the students' names and one to store their grades. The names array should be a one-dimensional array which stores strings representing the names of the students. The grades array should be a two-dimensional array which stores integers representing the grades the students received on each exam. Below is a suggested code for the two arrays: // Create an array for the students' names String[] students = new String[30]; // Create an array for the students' grades int[][] grades = new int[30][2]; The code first creates a one-dimensional array for the students' names, and then creates a two-dimensional array for the students' grades. Each row in grades represents a student and each column represents their grades for the two exams. Once the arrays are created, the instructor can store the students' names in the students array and assign them their grades in the grades array. For example, if the student at index 0 received grades of 85 and 90 on the two exams, the code would look like this: students[0] = "John"; grades[0][0] = 85; grades[0][1] = 90;

Answered by Lauren Palmer

We have mentors from

Contact support