Java Program Helpers Come in Please

  • Context: Comp Sci 
  • Thread starter Thread starter remaan
  • Start date Start date
  • Tags Tags
    Java Program
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
5 replies · 2K views
remaan
Messages
132
Reaction score
0
Java Program Helpers Come in Please !

Homework Statement



I am writting a program which asks the user to enter his email address, and then prints - according to five conditions - if his address is valid or not .

1. there should be exactly one @ in the address he enters.
2. there should be at least one '.' after the @ but not immdetly after it
3. '.' can not be the last character in the address.
4. After @ there should be never two '.' in a row.
5. The @ should not be the first one.





The Attempt at a Solution




The only thing I could think of is the last condition. I think I could that by using charAt(0)!= @

And, for the remaining conditions I thought about making a new method ?
using void so it does not return any thing, only checks

What do you think
 
Physics news on Phys.org


Thanks Thomas,

But I still have to create a new method, using void as will not return any thing
Right?
 


Look at the examples on the website I posted. It's basically one line of code, you don't need an extra method for that.
 


Ya, I looked at your website. But still am not sure how to do it " only one line of code "

What understod is : I have to make 2 classess in side the main class ?

However, still I can use methods to do it, right ?