project directions:
1. Create a class called Student that has name, grade, house as instance variables
2. Create a constructor that take these (3) items as parameters and sets them to your private instance/global variables
3. Next, create a test class StudentTest
4. Inside of StudentTest create an ArrayList called myList
5. Create a loop that runs 5 times. It asks the user for the (3) pieces of information (name, grade, house). Take that info and create and Student object that will be added to the ArrayList
Test class
Code :public class StudentTest { /** * main * @param args */ public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); ArrayList<Student> myList = new ArrayList<Student> (); for (int i = 0; i < 5; i++) { System.out.println("What is the name of the student?"); String name = keyboard.nextLine(); System.out.println("What is his/her house?"); String house = keyboard.nextLine(); System.out.println("What is his/her grade? Numbers only, please."); int grade = keyboard.nextInt(); myList.add(i, new Student(name, grade, house)); } } }
Student class
Code :public class Student { //instance variables String name; int grade; String house; /** * student constructor * @param name * @param grade * @param house */ public Student(String name, int grade, String house) { this.name = name; this.grade = grade; this.house = house; } }
Console:
What is the name of the student?
Bob
What is his/her house?
Random
What is his/her grade? Numbers only, please.
9
What is the name of the student?
What is his/her house?
I couldn't type in the name of the second student because the next line "What is his/her house?" came up with it.

