Question: Programming: ArrayLists The class Student, shown below, which holds name, major and credits earned for a student. Using the built-in Java ArrayList students Write a
Programming: ArrayLists
The class Student, shown below, which holds name, major and credits earned for a student.
Using the built-in Java ArrayList
Write a method
public static double averageCreditsForMajor(ArrayList
which returns the average creditsEarned for all the students in the given major from the list.
public class Student { private String name; private String major; private double creditsEarned; public String getName() { return name; } public void setName(String name) { this.name = name;} public String getMajor() { return major; } public void setMajor(String major) { this.major = major; } public double getCreditsEarned() { return creditsEarned; } public void setCreditsEarned(double credits) { credits = creditsEarned; } public Student(String nam, String maj, double credits) { name = nam; major = maj; creditsEarned= credits; } } Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
