Inside your lab11 directory, create a file named Lab11b.java. Inside Lab11b.java write a program that runs as follows.
-
- Ask the user to enter a first name, last name and student ID.
- Read in the data from the keyboard and store the data in local variables.
- Create an instance of the Student class using the data read from the keyboard.
- Print to the screen the String that is returned by the instance’s toString method.
- Print to the screen the student’s last name using the instance’s getter method.
- Print to the screen the student’s first name using the instance’s getter method.
- Print to the screen the student’s ID using the instance’s getter method.
- Set the student’s last name to “Bunny” using the instance’s setter method.
- Set the student’s first name to “Bugs” using the instance’s setter method.
- Set the student’s ID to 3000 using the instance’s setter method.
- Print to the screen the String that is returned by the instance’s toString method.
- Set the student’s ID to 0 using the instance’s setter method.
- Print to the screen the string that is returned by the instance’s toString method.
- Create an instance of the Student class for a student named “Joe Black” and whose student id is 1357.
- 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“.
- Create a third instance of the Student class for a student named “Miko Marra” whose student id is 1357.
- 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.