0

i need to write a method that in my program student object for the student class that validates it's own data.
background on student class:
it's a program that ask for a name of a student and 3 test scores and print the highest , the lowest and the average.

i need to write a data validation method in which if the user enter a blank name(ex. " "), it prints an error message. if the data entered is valid (ex. "Austin"), it returns the value null.
i will really appreciate you help.

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by javaAddict
0

We're not going to write it for you so show us some effort and explain why you need help/ what exactly you need help with.

0

i need to write a data validation method in which if the user enter a blank name(ex. " "), it prints an error message. if the data entered is valid (ex. "Austin"), it returns the value null.

You just said the solution:
The method will have as argument a String.
If it is empty return a message (String)
else return null (a String can be null)
Use the trim and length method to do the checking.
Check the String API for these methods

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.