Question

In: Computer Science

(JAVA) Write a program that maintains student test scores in a two-dimesnional array, with the students...

(JAVA) Write a program that maintains student test scores in a two-dimesnional array, with the students identified by rows and test scores identified by columns. Ask the user for the number of students and for the number of tests (which will be the size of the two-dimensional array). Populate the array with user input (with numbers in {0, 100} for test scores). Assume that a score >= 60 is a pass for the below.
Then, write methods for:

Computing the number of tests that each student passed


Computing the number of students passed for each test

The methods should accept a two-dimensional array as one argument and a specific student number (for (a)) or a specific test number (for (b)) as the other argument. The methods should return the relevant counts.
Call the above methods (from main) by passing the two-dimensional array that contains the test scores, for each student (for (a)) and then for each test (for (b)). Print the counts.

Solutions

Expert Solution

import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Please enter number of students:");
int noOfStudents = input.nextInt();
System.out.print("Please enter number of Tests:");
int noOfTests = input.nextInt();
int[][] testScoresOfStudents = new int[noOfStudents][noOfTests];
for(int nS = 0;nS<noOfStudents;nS++) {
System.out.println("\nTest scores of student"+nS+" :" );
for(int nT= 0 ; nT<noOfTests;nT++) {
   System.out.print("Test "+nT+" score:" );
   testScoresOfStudents[nS][nT] = input.nextInt();
}
}
System.out.println("Tests passed by student 0:"+testsPassedByAStudent(testScoresOfStudents,0));
System.out.println("No of students passed Test 0:"+studentsPassedAParticularTest(testScoresOfStudents,0));
}
public static int testsPassedByAStudent(int[][] testScoresOfStudents,int studentId ) {
   int count = 0;
   for(int i = 0;i<testScoresOfStudents[studentId].length;i++) {
       if(testScoresOfStudents[studentId][i]>=60)
           ++count;
   }
   return count;
}
public static int studentsPassedAParticularTest(int[][] testScoresOfStudents,int testId ) {
   int count = 0;
   for(int i = 0;i<testScoresOfStudents.length;i++) {
       if(testScoresOfStudents[i][testId]>=60)
           ++count;
   }
   return count;
}
}


Related Solutions

Java: Declare a two-dim array that represents five students with four test scores. Assign 100 for...
Java: Declare a two-dim array that represents five students with four test scores. Assign 100 for all tests to all students. Change the 3rd student’s test 2 to 50. Change the last student’s last test to 87 Print out all test scores. Calculate the total points of all tests of all students
Write JAVA program that finds 3 students with the best scores. The program asks users for...
Write JAVA program that finds 3 students with the best scores. The program asks users for scores of 5 students. The program prints the first, second, third place students and scores. You can assume that there is no two students with the same score. <EXAMPLE> enter the score of each student score of student 1: 50 score of student 2: 70 score of student 3: 30 score of student 4: 90 score of student 5: 40 1st place is student...
Write a java code that gets student test scores from the user. Each test score will...
Write a java code that gets student test scores from the user. Each test score will be an integer in the range 0 to 100. Input will end when the user enters -1 as the input value. After all score have been read, display the number of students who took the test, the minimum score, the maximum score, the average score (with decimal point, and the number of A where an A is a score in the range 90-100.
Write a program that reads students’ names followed by their test scores. The program should output...
Write a program that reads students’ names followed by their test scores. The program should output each student’s name followed by the test scores and the relevant grade. It should also find and print the highest test score and the name of the students having the highest test score. Student data should be stored in a struct variable of type studentType, which has four components: studentFName and studentLName of type string, testScore of type int (testScore is between 0 and...
Instructions Write a Java program that asks the user t enter five test scores. The program...
Instructions Write a Java program that asks the user t enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program: * calcAverage -- This method should accept five test scores as arguments and return the average of the scores. * determineGrade -- This method should accept a test score as an argument and return a letter grade for the score, based on the following...
Write a C++ program that reads a file consisting of students’ test scores in the range...
Write a C++ program that reads a file consisting of students’ test scores in the range 0–200. It should then determine the number of students having scores in each of the following ranges: 0–24, 25–49, 50–74, 75–99, 100–124, 125–149, 150–174, and 175–200. Output the score ranges and the number of students. (Run your program with the following input data: 76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176,...
Write a Java program that will use a two-dimensional array and modularity to solve the following...
Write a Java program that will use a two-dimensional array and modularity to solve the following tasks: Create a method to fill the 2-dimensional array with (random numbers, range 0 - 30). The array has rows (ROW) and columns (COL), where ROW and COL are class constants. Create a method to print the array. Create a method to find the largest element in the array Create a method to find the smallest element in the array Create a method to...
Write a Java program that will use a two-dimensional array and modularity to solve the following...
Write a Java program that will use a two-dimensional array and modularity to solve the following tasks: 1. Create a method to generate a 2-dimensional array (random numbers, range 0 - 500). The array has ROW rows and COL columns, where ROW and COL are class constants. 2. Create a method to print the array. 3. Create a method to find the largest element in the array 4. Create a method to find the smallest element in the array 5....
Write a Java program that will use a two-dimensional array and modularity to solve the following...
Write a Java program that will use a two-dimensional array and modularity to solve the following tasks: Create a method to generate a 2-dimensional array (random numbers, range 0 - 500). The array has ROW rows and COL columns, where ROW and COL are class constants. Create a method to print the array. Create a method to find the largest element in the array Create a method to find the smallest element in the array Create a method to find...
Write a Java program that reads a list of integers into an array. The program should...
Write a Java program that reads a list of integers into an array. The program should read this array from the file “input.txt”. You may assume that there are fewer than 50 entries in the array. Your program determines how many entries there are. The output is a two-column list. The first column is the list of the distinct array elements; the second column is the number of occurrences of each element. The list should be sorted on entries in...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT