Java Program Helpers Come in Please

  • Context: Comp Sci 
  • Thread starter Thread starter remaan
  • Start date Start date
  • Tags Tags
    Java Program
Click For Summary

Discussion Overview

The discussion revolves around a homework problem involving the validation of email addresses in a Java program. Participants explore various approaches to implement the validation based on specified conditions.

Discussion Character

  • Homework-related
  • Technical explanation

Main Points Raised

  • The original poster outlines five specific conditions that an email address must meet to be considered valid.
  • Some participants suggest using regular expressions as a concise solution to validate the email address in a single line of code.
  • There is a discussion about whether an additional method is necessary for the validation process, with some arguing it may not be needed if using regular expressions.
  • The original poster expresses uncertainty about implementing the solution in one line and whether multiple classes are required within the main class.
  • Participants question the necessity of using methods while also considering the use of a void method for validation.

Areas of Agreement / Disagreement

Participants have differing views on the necessity of creating additional methods for validation, with some advocating for a simpler approach using regular expressions while others consider the use of methods as beneficial.

Contextual Notes

There are unresolved questions regarding the implementation details, such as the structure of classes and methods, and the specific use of regular expressions versus traditional validation methods.

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?
 


Please show us your coding attempt.
 


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 ?
 

Similar threads

  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 2 ·
Replies
2
Views
7K
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K