Question
int []grades = {60, 72, 78, 95, 88, 82, 60, 97, 90, 85, 78, 75, 89, 53, 68, 83, 88, 75, 63, 94};
String []gender = {"M", "M", "F", "F", "M", "F", "F", "M", "M", "F", "F", "M", "F", "F", "M", "F", "F", "M", "M", "F"};
String []major = {"Math", "Math", "Physics", "Art", "Art", "Art", "Science", "Science", "Physics", "Art", "Math", "Math", "Math", "Science", "Science", "Physics", "Art", "Math", "Math", "Math"};
Store the three arrays in the main method. Write methods called method1, method2 and method3 to compute:
• Number of student’s in Math major.
• Total number of males in Math major.
• Total number of males in Math major who got a grade above 90 .
Return the values from the three methods back into the main methods and print from within.
Solution Preview
These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.
public class StudentsGrades {public static int method1(String[] arr) {
int count = 0;
for(int i = 0; i < arr.length; i++) {
if(arr[i].equals("Math"))
count++;
}
return count;
}
public static int method2(String[] arr1, String[] arr2) {
int count = 0;
for(int i = 0; i < arr1.length; i++) {
if(arr1[i].equals("Math") && arr2[i].equals("M"))
count++;
}
return count;
}...
By purchasing this solution you'll be able to access the following files:
Solution.java.