java - Generating username with given information from the user -
hi im can me program ? professor ask program information user , generate 6 letter username lastname , firstname of user. first 3 letters of user name first 3 letters of firstname , other 3 last 3 letters of lastname of user. , need test log-in module test if username , password match on generated username , user inputted password
as far im doing cant find answer on , our professor didn't teach this , im struggling right now.
this program right now>>>
public static inputstreamreader r = new inputstreamreader(system.in); public static bufferedreader = new bufferedreader(r); public static void main(string[]args) throws exception{ string lname,fname,mi; int age,bday; float pass; system.out.print("enter last name: "); lname=i.readline(); system.out.print("enter first name: "); fname=i.readline(); system.out.print("enter middle name: "); mi=i.readline(); system.out.print("age: "); age=integer.parseint(i.readline()); system.out.print("birthday (mm/dd/yy) :"); bday=integer.parseint(i.readline()); system.out.println("password must 4-6 digit combination"); system.out.print("enter password : "); pass=float.parsefloat(i.readline()); system.out.println("please wait while generating username"); for(int j=0;j<=35;j++) { try{ thread.sleep(100); } catch(interruptedexception ex) { //do nothing } system.out.print("*"); } }
can me please....
you can just:
string username = fname.substring(0,3) + lname.substring(lname.length() - 3, lname.length());
you should check fname , lname have minimum length of 3 characters, or exception
Comments
Post a Comment