StudentLoans class
5 Code a method displayAllStudents(). This method has no parameters and is void. This method displays all the objects in the array.
a) Display a heading .
b) Loop through the array and use the show() of every object to display the object details. c) Print a line after each object is displayed. Example of expected output:
Displaying all students
--------------------
Student details
Name: Smittie
Student number: 12345
Loan amount: 10000.0
-------------------------
Student details Name: Jannie
Student number: 67543
Loan amount: 50000.0
-------------------------
public class StudentLoans {
private Student[] students;
public void displayAllStudents() {
System.out.println("Displaying all students ");
for (Student student : students) {
System.out.println("--------------------");
student.show();
}
}
}
Comments
Leave a comment