Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

OOP and user validation?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi??
i have a problem in java...and i'm not quite sure how to solve it, and was wandering if anyone would be able to help me out here...
i have started something but not sure what to do next.
Here is the problem:
Problem 1
A program accepts identification number, first name, last name, and email address of a user. It validates the data as per following specifications:
.identification number � no blanks, four numerical characters;
.first name � no blanks, all alphabetical characters;
.last name � same as for first name;
.email address�
.no blanks;
.only one �@�character;
,there is at least one word before �@�, and at least two words after �@�, both words(following �@�) joined by �.�, no space between the words before and after the �.� character.
Assume that there are maximum of two words following �@�character, and there are maximum of 25 characters in the email address.
If any of the data item is invalid, program displays an appropriate message to the user and asks for re-entry of that item.
When all data items entered are valid, program creates a password for the user by joining:
.first two characters of first name;
.2nd and 3rd characters of identification
.last three characters from the last name;
in above order.
Password is then relayed back to user. Later then enters this password and program then checks that user has entered the correct password (as created for him/her), and displays the message to the user accordingly.
You do not need to create any special user interface but must utilize string and array processing functions
and here is my source code so far.. if any one helpful enough could fix the program for me that would be much appreciated..thanks
kind regards,
Atif.
public class UserValidation {
//declare variables
private int id;
private String firstname;
private String lastname;
private String email;
private BufferedReader input = new BufferedReader // Handles console input
(new InputStreamReader(System.in));
public int getId() throws IOException{
System.out.println("Input UserID:");
id = Integer.parseInt(input.readLine());
getId();
}
return id;
}
public String getfName(){
return firstname;
}
public String getlName(){
return lastname;
}
public String getEmail(){
return id;
}
public void display(){
System.out.println(" " + getId() + getfName() + getlName() + getEmail());
}
public static void main (String args[]){
UserValidation user = new UserValidation();
user.display();
}
}
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
saab,
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner!
 
saab
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
hi? sorry my real name is Atif Abbas
...
so can some one help me out with my project please...
Atif
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hello Atif,
Two Things:
  • Please change your display name to comply with The JavaRanch Naming Policy.
  • When posting code, please surround the code with the [ code ] and [ /code ] ubb tags.
  • Thank You
     
    Dirk Schreckmann
    Sheriff
    Posts: 7023
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Report post to moderator
    Your code won't compile.
    I'd suggest that you write a very simple program to just get one piece of information. Once you get that working, then try dealing with multiple attributes and the required manipulations.
    Do you know how to get a single input from the user and display this input?
    Are you sure this is an advanced Java topic?
     
    Ranch Hand
    Posts: 1365
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Report post to moderator
    This is the sort of thing regular expressions handle very smoothly, but I'm not sure that's the best solution for you (regex is a language unto itself, plus you need jdk 1.4 to run it).
     
    Dirk Schreckmann
    Sheriff
    Posts: 7023
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Report post to moderator
    It appears you'd rather continue this conversation in the beginners' forum...
     
    Yeah, but how did the squirrel get in there? Was it because of the tiny ad?
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com
      Bookmark Topic Watch Topic
    • New Topic