Question

In: Computer Science

You will need to use only two arrays:  One array of type int to store...

You will need to use only two arrays:One array of type int to store all the ID's

One two‐dimensional array of type double to store all the scores for all quizzes

Note: The two dimensional array can be represented also with the rows being the students and the columns being the quizzes.

How to proceed:

1. Declare the number of quizzes as a constant, outside the main method. (Recall that identifiers for constants are all in CAPITAL_LETTERS.)

2. Ask the user how many students are in the class, so you can set the length of all the arrays.

3. Allocate 2 arrays, one one‐dimensional and the other two‐dimensional, that will store the data.

4. Use two nested FOR loops to retrieve and store all the data.

5. Use another two nested FOR loops to  

a. Output the final score for each student.

b. Keep track of all scores to later compute the average for the class.

6. Calculate and Output the average for the class.

Format all floating‐point numbers to 2 decimal places.

Please leave comments on the program so i can give you a thumbs up :)!

also, this is for java language

Solutions

Expert Solution

SOURCE CODE:

*Please follow the comments to better understand the code.

**Please look at the Screenshot below and use this code to copy-paste.

***The code in the below screenshot is neatly indented for better understanding.



import java.util.Scanner;

public class StudentArrayDemo
{
    // 1. declare the constants
     private static final int  NUM_OF_QUIZZES=3;

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        // 2.  Ask the user how many students are in the class,
        // so we can set the length of all the arrays.
        System.out.print("Enter how many students are in the class: ");
        int n=scanner.nextInt();

        // 3. Allocate 2 arrays, one one‐dimensional and the other two‐dimensional, that will store the data.
        int[] studentIds=new int[n];
        double[][] scores=new double[n][NUM_OF_QUIZZES];

        // 4. Use two nested FOR loops to retrieve and store all the data.
        for(int i=0;i<n;i++)
        {
            System.out.print("Enter "+NUM_OF_QUIZZES+" scores for student "+(i+1)+" : ");
            for (int j = 0; j < NUM_OF_QUIZZES; j++)
            {
                scores[i][j]=scanner.nextDouble();
            }
        }

        // 5. Use another two nested FOR loops to
        //
        //a. Output the final score for each student.
        //b. Keep track of all scores to later compute the average for the class.
        double sumOfClass=0;
        for(int i=0;i<n;i++)
        {
            double sum=0;
            for (int j = 0; j < NUM_OF_QUIZZES; j++)
            {
                sum+= scores[i][j];
            }
            System.out.printf("Final Score for student %d is %.2f\n",(i+1),sum);
            sumOfClass+=sum;
        }
       // 6.  Calculate and Output the average for the class.
        double avgOfClass=sumOfClass/(n);
        System.out.printf("\n\nThe Average of the class is: %.2f",avgOfClass);
    }
}

=========


Related Solutions

. As input you are given two arrays: an array of numbers ? and an array...
. As input you are given two arrays: an array of numbers ? and an array ? of queries where each query is a target number. The array ? is unsorted and may contain duplicates. Your goal is, for each query ? in the array ?, count the number of pairs in the array ? that sums up to ?; that is, the number of distinct pairs of indices [?, ?], with ? < ?, such that ?[?] + ?[?]...
In c++ Array expander Write a function that accepts an int array and the arrays size...
In c++ Array expander Write a function that accepts an int array and the arrays size as arguments. The function should create a new array that is twice the size of the argument array. The function should create a new array that is twice the size of the argument array. The function should copy the contents of the argument array to the new array and initialize the unused elements of the second array with 0. The function should return a...
1. Maintain two arrays for use in “translating” regular text to “leetspeak”: (a) One array will...
1. Maintain two arrays for use in “translating” regular text to “leetspeak”: (a) One array will contain the standard characters: char[] letters = {'a', 'e', 'l', 'o', 's', 't'}; (b) The other will contain the corresponding symbols: char[] symbols = {'@', '3', '1', '0', '$', '7'}; 2. Prompt the user to enter a full sentence with all lower-case characters, then store it in a variable to be used later. (a) You can (optionally) manually convert the string to all lower-case...
A.) myNums is an array of 50 elements of type int and k is an int...
A.) myNums is an array of 50 elements of type int and k is an int variable. For which one we get the index of out of bounds? a. for (k = 0; k <= 49; k++)     cout << myNums[k] << " "; b. for (k = 1; k < 50; k++)     cout << myNums[k] << " "; c. for (k = 0; k <= 50; k++)     cout << myNums[k] << " "; d. for (k =...
3. Array Operations 3-1 Write a function, equalsArray that when passed two int arrays of the...
3. Array Operations 3-1 Write a function, equalsArray that when passed two int arrays of the same length that is greater than 0 will return true if every number in the first array is equal to the number at the same index in the second array. If the length of the arrays is less than 1 the function must return false. For example, comparing the two arrays, {1,2,3,4,5} and {1,2,3,4,5} would return true but the two arrays {3,7} and {3,6}...
Ceate a two dimensional array of int type to hold scores (on a scale of 0...
Ceate a two dimensional array of int type to hold scores (on a scale of 0 to 100) for 10 students (row) for 3 courses (columns) and initialize the array with your preferred data. All the students get 10 bonus points for course #2 (index 1) . Use for a loop to add the bonus points. c programming language
int[]array={-40 ,60 ,78 ,-51 ,65 ,-95 ,77 ,-48 ,-66 ,71}; Create two int arrays called negative...
int[]array={-40 ,60 ,78 ,-51 ,65 ,-95 ,77 ,-48 ,-66 ,71}; Create two int arrays called negative and positive of length 10. Go through the given array and place the negative values into the array called negative and the positive values into the array called positive. Write code to find the smallest value in the given array and print the value out. Write code to find the largest value in the given array and print it out. Create an int array...
A. Arrays An array is basically of collection of related variables of the same type. For...
A. Arrays An array is basically of collection of related variables of the same type. For example, a collection of grades of students, a collection of salary of employees of a company, etc. When working with student grades, for example, we can then perform statistical computations on that set of data to obtain more meaningful information. In this part of the lab, you will write a complete C++ program named Lab6A.cpp that allows the user to enter the grades of...
Java: int[]array={-40 ,60 ,78 ,-51 ,65 ,-95 ,77 ,-48 ,-66 ,71}; 1)     Create two int arrays called...
Java: int[]array={-40 ,60 ,78 ,-51 ,65 ,-95 ,77 ,-48 ,-66 ,71}; 1)     Create two int arrays called negative and positive of length 10. Go through the given array and place the negative values into the array called negative and the positive values into the array called positive. 2)     Write code to find the smallest value in the given array and print the value out. 3)     Write code to find the largest value in the given array and print it out. 4)     Create an int...
public class SumMinMaxArgs { private int[] array; // You will need to write the following: //...
public class SumMinMaxArgs { private int[] array; // You will need to write the following: // // 1. A constructor that takes a reference to an array, // and initializes an instance variable with this // array reference // // 2. An instance method named sum, which will calculate // the sum of the elements in the array. If the array // is empty (contains no elements), then this will // will return 0. You will need a loop for...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT