Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Exercise 17 in Java - please note all parts of assignment - thank you For this e

ID: 658280 • Letter: E

Question

Exercise 17 in Java - please note all parts of assignment - thank you

For this exercise, you will implement two programs that allow the user to enter grades in a gradebook. The first program will use one-dimensional arrays, and the second program will use two-dimensional arrays. Folder name: A170_E17_YourLastName_YourFirstName Write an application that prints out the final grade of the students in a class and the average for the whole class. There are a total of 3 quizzes. You will need 4 arrays: An array of type int to store all the ID's An array of type double to store all scores for quiz 1 An array of type double to store all scores for quiz 2 An array of type double to store all scores for quiz 3. Example: Assume there are 10 students in the class, then the id array will have 10 indices. Each quiz array will store in the index that corresponds to the student the score for the quiz. Student with ID 154, at index 4, has taken all three quizzes with scores 75.0 (quiz 1), 78.0 (quiz 2) and 87.0 (quiz 3). You are free to start entering your values into the second array element (that would array index =1). Just remember that your array will need to be 1 element larger than the user requests.

Explanation / Answer

Part -1

ClassAverage1D.java

import java.util.Scanner;

public class ClassAverage1D {

   public static void main(String[] args) {

       Scanner input = new Scanner(System.in);

       System.out.println("How many Students in the class ?");

       int numberOfStudents = input.nextInt();

       int[] studentIds = new int[numberOfStudents];

       double[] quiz1 = new double[numberOfStudents];

       double[] quiz2 = new double[numberOfStudents];

       double[] quiz3 = new double[numberOfStudents];

       for (int i = 0; i < numberOfStudents; i++) {

           System.out.println("Enter The Student Id: ");

           studentIds[i] = input.nextInt();

           System.out.println("Enter score for Quiz 1: ");

           quiz1[i] = input.nextDouble();

           System.out.println("Enter score for Quiz 2: ");

           quiz2[i] = input.nextDouble();

           System.out.println("Enter score for Quiz 3: ");

           quiz3[i] = input.nextDouble();

       }

       double[] average = new double[numberOfStudents];

       double classTotal = 0.0;

       for (int i = 0; i < numberOfStudents; i++) {

           average[i] = (quiz1[i] + quiz2[i] + quiz3[i]) / 3;

           classTotal = classTotal + average[i];

       }

       for (int i = 0; i < numberOfStudents; i++) {

           System.out.println("ID " + studentIds[i] + " - Final Grade: " + average[i]);

       }

       System.out.println("Class Avergae: " + classTotal/numberOfStudents);

   }

}

Sample Output :

How many Students in the class ?

4

Enter The Student Id:

111

Enter score for Quiz 1:

100

Enter score for Quiz 2:

95

Enter score for Quiz 3:

90

Enter The Student Id:

222

Enter score for Quiz 1:

90

Enter score for Quiz 2:

85

Enter score for Quiz 3:

80

Enter The Student Id:

333

Enter score for Quiz 1:

100

Enter score for Quiz 2:

100

Enter score for Quiz 3:

100

Enter The Student Id:

444

Enter score for Quiz 1:

90

Enter score for Quiz 2:

90

Enter score for Quiz 3:

90

ID 111 - Final Grade: 95.0

ID 222 - Final Grade: 85.0

ID 333 - Final Grade: 100.0

ID 444 - Final Grade: 90.0

Class Avergae: 92.5

Part -2

ClassAverage2D.java

import java.util.Scanner;

public class ClassAverage2D {

   public static void main(String[] args) {

       Scanner input = new Scanner(System.in);

       System.out.println("How many Students in the class ?");

       int numberOfStudents = input.nextInt();

       int[] studentIds = new int[numberOfStudents];

       double[][] quiz = new double[3][numberOfStudents];

       for (int i = 0; i < numberOfStudents; i++) {

           System.out.println("Enter The Student Id: ");

           studentIds[i] = input.nextInt();

           for (int j = 0; j < 3; j++) {

               System.out.println("Enter score for Quiz " + j + 1 + ":");

               quiz[j][i] = input.nextDouble();

           }

       }

       double[] average = new double[numberOfStudents];

       double classTotal = 0.0;

       for (int i = 0; i < numberOfStudents; i++) {

           average[i] = (quiz[0][i] + quiz[1][i] + quiz[2][i]) / 3;

           classTotal = classTotal + average[i];

       }

       for (int i = 0; i < numberOfStudents; i++) {

           System.out.println("ID " + studentIds[i] + " - Final Grade: " + average[i]);

       }

       System.out.println("Class Avergae: " + classTotal / numberOfStudents);

   }

}

Sample output

How many Students in the class ?

4

Enter The Student Id:

111

Enter score for Quiz 1:

100

Enter score for Quiz 2:

90

Enter score for Quiz 3:

95

Enter The Student Id:

222

Enter score for Quiz 1:

90

Enter score for Quiz 2:

80

Enter score for Quiz 3:

85

Enter The Student Id:

333

Enter score for Quiz 1:

100

Enter score for Quiz 2:

100

Enter score for Quiz 3:

100

Enter The Student Id:

444

Enter score for Quiz 1:

90

Enter score for Quiz 2:

90

Enter score for Quiz 3:

90

ID 111 - Final Grade: 95.0

ID 222 - Final Grade: 85.0

ID 333 - Final Grade: 100.0

ID 444 - Final Grade: 90.0

Class Avergae: 92.5

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote