Username Generator using java
CODE :
import java.util.*;
class Username{
public static void ungenerator(String fname, String lname, String phno)
{
String ln= lname.substring(0,2);
int l = phno.length();
String phn = "";
for (int i = 1; i < l; i += 2) {
phn += String.valueOf((int) Math.pow(Character.getNumericValue(phno.charAt(i)), 2));
}
String ph=phn.substring(0,2);
String fn = fname.replaceAll("a", "x");
String username = fn+ln+"@"+ph;
System.out.println("Suggested Username : "+username);
}
public static void main(String args[]){
Scanner scanner = new Scanner(System.in);
System.out.print("Please enter your First Name : ");
String fname = scanner.next();
System.out.print("Please enter your Last Name : ");
String lname = scanner.next();
System.out.print("Please enter your Phno : ");
String phno = scanner.next();
ungenerator(fname,lname,phno);
}}
Inputs and Outputs :