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();

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();
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

1 Expert Approved Answer
Step: 1 Unlock

public class Student String name int score 1 public Student public String ge... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (1 attachment)

Word file Icon

1013-C-S-O-S (687).docx

120 KBs Word File

Students Have Also Explored These Related Operating System Questions!