Question: JAVA A class roster has students in it, as shown below. A Student has a name, and an age. Complete the class public class Student
JAVA
A class roster has students in it, as shown below. A Student has a name, and an age. Complete the class public class Student { private String name; private int age; ...
with
A default constructor
set methods for the two instance fields: for age it throws an IllegalArgumentException if the value is <= 0 or > 150
Using the method setAge you have just written, write a loop that reads a number from a Scanner (you can use nextInt() for that) and tries to fill it into the age of a given Student instance until that is successful. Assume the following definition and construct the code after that. [10]
Student s = new Student();
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
