Lab 11b – Test the Student Class

Inside your lab11 directory, create a file named Lab11b.java. Inside Lab11b.java write a program that runs as follows.


    1. Ask the user to enter a first name, last name and student ID.
    2. Read in the data from the keyboard and store the data in local variables.
    3. Create an instance of the Student class using the data read from the keyboard.
    4. Print to the screen the String that is returned by the instance’s toString method.
    5. Print to the screen the student’s last name using the instance’s getter method.
    6. Print to the screen the student’s first name using the instance’s getter method.
    7. Print to the screen the student’s ID using the instance’s getter method.
    8. Set the student’s last name to “Bunny” using the instance’s setter method.
    9. Set the student’s first name to “Bugs” using the instance’s setter method.
    10. Set the student’s ID to 3000 using the  instance’s setter method.
    11. Print to the screen the String that is returned by the instance’s toString method.
    12. Set the student’s ID to 0 using the instance’s setter method.
    13. Print to the screen the string that is returned by the instance’s toString method.
    14. Create an instance of the Student class for a student named “Joe Black” and whose student id is 1357.
    15. Use the equals method to print to the screen “Yep, equal” if the two instances of the Student class in your program are considered equal; otherwise print “not equal“.
    16. Create a third instance of the Student class for a student named “Miko Marra” whose student id is 1357.
    17. Use the equals method to print to the screen “Yep, equal” if the last two instances of the Student class in your program are considered equal; otherwise print “not equal“.

Compile, debug, test, push.

© 2024, Eric. All rights reserved.