Programming Project 3.1 to generate username for new computer account by sing FN, LN and random number from 00 to 99:
//********************************************************************************
// PP3_1.java
// Programming Project 3.1
// To generate user name for new computer account by using first name, last name
// and random number from 00 to 99
//*********************************************************************************
import java.util.Scanner;
public class PP3_1
{
public static void main(String[] args)
{
String First_Name;
String Last_Name;
String Output;
Scanner scan = new Scanner(System.in);
System.out.print("Please Enter First Name: ");
First_Name=scan.next();
System.out.print("Please Enter Last Name: ");
Last_Name=scan.next();
System.out.println("Name is: "+First_Name+" "+Last_Name);
int randomNum = 10 + (int)(Math.random()*99);
Output=First_Name.substring(0,1)+Last_Name.substring(0,5)+randomNum;
System.out.println("User name is: "+Output);
}
}
No comments:
Post a Comment