Question: A Student object should validate its own data. The client runs this method, called validateData(), with a Student object, as follows: String result = student.validateData();
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.
Step by Step Solution
3.58 Rating (172 Votes )
There are 3 Steps involved in it
public class Student String name int score 1 public Student public String ge... View full answer
Get step-by-step solutions from verified subject matter experts
Document Format (1 attachment)
1013-C-S-O-S (687).docx
120 KBs Word File
