A Student object should validate its own data. The client runs this method, called validateData(), with a
Question:
validateData(), with a Student object, as follows:
String result = student.validateData();
if (result == null)
else
System.out.println(result);
If the student's data are valid, the method returns the value null; otherwise, the method returns a string representing an error message that describes the error in the data. The client can then examine this result and take the appropriate action.
A student's name is invalid if it is an empty string. A student's test score is invalid if it lies outside the range from 0 to 100. Thus, sample error messages might be
"SORRY: name required" and
"SORRY: must have 0 <= test score <= 100".
Implement and test this method.
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Related Book For
Question Posted: