Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to create a code based off of what the users first name and last name are

ID: 3798423 • Letter: I

Question

I need to create a code based off of what the users first name and last name are along with a random set of numbers no longer than 10 characters

Scenario: You have been appointed by the CS department to create a username generator to create CS email accounts automatically. The CS email will have the following format: Username@cs.utep.du. Your username must have a limit of 10 characters. Your program, will provide three different options of usernames using the input from the user. You will follow these guidelines: lastnamefirstname ##(where ## two random digits (1-9)). firstnamechar1lastname##(where ## last two digits of birth year) ##lastnamefirst3charsfirstnamelast3chars (taking the first 3 characters from last name and last 3 characters from first name. Where ## is the length of your last name) *If your username Is longer than 10 characters, your program will cut the exceeding characters from the Last Name. Program Output Sample) Please enter your first name: Claudia Please enter your last name: Casas Please enter Date of birth in format MMDDYY: 021085 Your username options are: casasclaudia11 ccasas85 05casdia Please select the user name from the following options: 2 Your email address has been generated:ccasas85@cs.utep.edu

Explanation / Answer

//Tested on eclipse

import java.util.Scanner;

public class MailGeneration {
   /**
   * Maximum length of username
   */
   private static int MAX_LENGTH = 10;

   /**
   * generate pin of 2 digit
   *
   * @return string
   */
   public static String generatePIN() {

       // generate a 2 digit integer 10 < 99
       int randomPIN = (int) (Math.random() * 90) + 10;

       // Store integer in a string
       return randomPIN + "";

   }

   /**
   * Generating email for user
   *
   * @param fname
   * @param lname
   * @param dob
   */
   public static void generate(String fname, String lname, String dob) {
       Scanner input = new Scanner(System.in);
       int option;
       /**
       * here 2 denotes pin length
       */
       int remainLength = MAX_LENGTH - fname.length() - 2;
       /**
       * Generate pin for all 3 options
       */
       String pin1 = generatePIN();
       String pin2 = generatePIN();
       String pin3 = generatePIN();
       /**
       * Generating options according instructions
       */
       String option1 = fname + lname + pin1;
       String option2 = fname.charAt(0) + lname + pin2;
       String option3 = pin3 + lname.substring(0, 3) + fname.substring(fname.length() - 3, fname.length());
       System.out.println("your username options are:");
       System.out.println("Option 1:" + option1);
       System.out.println("Option 2:" + option2);
       System.out.println("Option 3:" + option3);

       System.out.print("Please select the user name from the following options:");
       option = input.nextInt();
       System.out.print("Your email address has been generated:");
       switch (option) {
       case 1:
           if (option1.length() < 10) {
               System.out.print(option1);
           } else {
               System.out.print(fname + lname.substring(0, remainLength) + pin1);
           }
           System.out.println("@cs.utep.edu");
           break;
       case 2:
           if (option2.length() < 10) {
               System.out.print(option2);
           } else {
               System.out.print(fname.charAt(0) + lname.substring(0, remainLength) + pin1);
           }
           System.out.println("@cs.utep.edu");

           break;
       case 3:
           System.out.print(pin3 + lname.substring(0, 3) + fname.substring(fname.length() - 3, fname.length()));
           System.out.println("@cs.utep.edu");
           break;
       default:
           System.out.println("Wrong choice");
       }
       input.close();
   }

   public static void main(String[] args) {
       /**
       * Variable declaration
       */
       String fname;
       String lname;
       String dob;
       /**
       * Prompt for user input
       */
       Scanner input = new Scanner(System.in);
       System.out.print("Please Enter your first Name:");
       fname = input.nextLine().toLowerCase();
       System.out.print("Please Enter your Last Name:");
       lname = input.nextLine().toLowerCase();
       System.out.print("Please Enter Date of birth in format MMDDYY:");
       dob = input.nextLine();
       /**
       * Calling mail generating
       */
       MailGeneration.generate(fname, lname, dob);
       input.close();
   }
}

/**************************output*********************/

Please Enter your first Name:Claudia
Please Enter your Last Name:Casas
Please Enter Date of birth in format MMDDYY:021085
your username options are:
Option 1:claudiacasas92
Option 2:ccasas78
Option 3:82casdia
Please select the user name from the following options:
2
Your email address has been generated:ccasas78@cs.utep.edu

/******************output2************************************/

Please Enter your first Name:Claudia
Please Enter your Last Name:Casas
Please Enter Date of birth in format MMDDYY:021085
your username options are:
Option 1:claudiacasas81
Option 2:ccasas74
Option 3:94casdia
Please select the user name from the following options:1
Your email address has been generated:claudiac81@cs.utep.edu

Thanks a lot

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote