StudentLoans class
1 Code a no-argument constructor. In this constructor, a) Add 2 Student objects to the Students array. b) Add 2 PostGraduate objects to the Students array. c) Set noOfStudents to 4.
2 Code a method menu() that returns an int value. This value represents the choice the user has made from the available menu options. a) Define a Scanner variable to read from the keyboard. b) Define an int value, named choice. c) Display a menu in the following format:
1: Add student
2: Display students
3: Display interest
4: Exit
d) Read the user’s choice from the keyboard.
e) Return the choice read from the keyboard.
import com.demo.Student;
import com.demo.PostGraduate;
public class StudentLoans {
private List<Student> students;
private int noOfStudents;
public StudentLoans() {
students = new ArrayList<Students>();
students.add(new Student());
students.add(new Student());
students.add(new PostGraduate());
students.add(new PostGraduate());
noOfStudents = 4;
}
public void menu() {
// here imple...
}
}
Comments
Leave a comment