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

as the picture below demonstrate (Java language)
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 erna me Your username must have a limit of 10 characters. Lab Assignment: Your program will provide three different options of usernames using the input from (30 points) Part 1) the user You will follow these guidelines: option 1 (where two random digits(-9) prin lautlfirst Uaa) lastnamefistnamemm option 2: first namecharllastname#tt (where tttte last two digits of birth year)Print option 3:#tlastnamefirst3charsfirstnamelast3chars (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 your program will cut the exceeding characters from the 10 characters, Last Name. ings Program output sample) Please enter your first name: Claudia OOD Please enter your last name: Casas Please enter Date of birth in format MMDDYY: 021085 Your username options are: Option 1: casasclaudia11 Option 2: ccasas85 Option 3: 05casdia Please select the user name from the following options: 2 Your email address has been generated: ccasas85 utep.edu

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//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:[email protected]

/******************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:[email protected]

Thanks a lot

Add a comment
Know the answer?
Add Answer to:
I need to create a code based off of what the users first name and last...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a Python program to create userids: You work for a small company that keeps the...

    Write a Python program to create userids: You work for a small company that keeps the following information about its clients: • first name • last name • a user code assigned by your company. The information is stored in a file clients.txt with the information for each client on one line (last name first), with commas between the parts. In the clients.txt file is: Jones, Sally,00345 Lin,Nenya,00548 Fule,A,00000 Your job is to create a program assign usernames for a...

  • In Java, How would I create a program that does this from user input? studentld: consists...

    In Java, How would I create a program that does this from user input? studentld: consists of the first two characters of the student's first name, student's birth year, and the last two characters of the last name. For instance, if the student's full name is John mith and birthyear is 1988, then the studentid will be jo1988th. s email: consists of the first name, dot, last name, and @pa2.com. For instance, if the student's full name is John Smith,...

  • so we will create a frame which will have label boxes for first name, last name,...

    so we will create a frame which will have label boxes for first name, last name, and date of birth. Input will be taken from the user and when the user fills the date box it should show calendar from where a user can pick a date. Give the color palette to the user which could have up to 10 colors and the user can choose a background from that color palate. Once the all is done we have two...

  • Using Python INST-FS-IAD-PROD.INS LAB1 Lab: Create User Account 2. get-password() #promt the user and create password, check the password fits the requirement USE the EXACT file names! Create a user...

    Using Python INST-FS-IAD-PROD.INS LAB1 Lab: Create User Account 2. get-password() #promt the user and create password, check the password fits the requirement USE the EXACT file names! Create a user login system. Your code should do the following: 3, create-user_name() #use this function to create the user name 1.Create your user database called "UD.txt", this should be in CSV format 4, write-file() #user this function to save the user name and password into "UD.txt" Deliverables: Sample: the data you saved...

  • Introduction to Java programming You will create a secure password. Ask a user to enter first...

    Introduction to Java programming You will create a secure password. Ask a user to enter first name and last name. (Allow for mixed case) Create a random integer from 10-99. Create the password string that consists of the upper case letter of the last letter of his/her first name, the random number, and the first three letters of his/her last name in lower case. Example someone with the name Rob Lee might have a password that looks like B56lee. Your...

  • Write a program that separately prompts the user for a first name and last name and...

    Write a program that separately prompts the user for a first name and last name and outputs a string containing the following information, in order: a. First letter of the user's name. b. First five letters of the user's last name. c. A random two-digit integer You must construct the desired string ensuring all characters are lowercase; output the identification string accordingly. Assume the last name contains at least 5 characters. You must use the Random (java.util.Random) class to generate...

  • in python 5.23 Login Create a program that prompts the user for a username and password....

    in python 5.23 Login Create a program that prompts the user for a username and password. The correct username should be python and the correct password should be csci 135. See below for example output. (Different messages depending on if user name or password are correct.) Only allow the user to make 3 attempts. Welcome to my secret program! Please enter your username: Trish Please enter your password: Duce Invalid username and password Please enter your username: Trish Please enter...

  • Create a folder named "TrainerApp". In that folder create the following files. Create a PHP file,...

    Create a folder named "TrainerApp". In that folder create the following files. Create a PHP file, "insert-user-form.php", with a form that has the following fields: - First Name (text) - Last Name (text) - Email (text) - Password (text) - Submit button Create another PHP file, "insert-exercise-form.php" with a form that has the following fields: - Exercise Name (text) - Description (text) - Demonstration Image (file) - Submit button Create another PHP file, "login-user-form.php" with a form that has the...

  • Lab 4: Databased Admin Tool Continued Python Objective: In the previous lab, you developed an admin tool for username an...

    Lab 4: Databased Admin Tool Continued Python Objective: In the previous lab, you developed an admin tool for username and password management. You accomplished the tasks with Dictionary or List. Here, use class to design your own data structure to accomplish a similar task. The UD.txt datafile: FIRST NAME, LAST NAME,USERNAME,PASSWORD Sam, DDal,sdd233,Pad231 Dave, Dcon,dcf987, BHYW4fw Dell, Grant,dgr803,Sb83d2d Mike, Kress,mkr212,UNNHS322 Lisa,Kate,lki065,dgw6234 Paul,Edward,ped332,9891ds Youyou,Tranten,ytr876,dsid21kk Nomi,Mhanken,nmh223,3282jd3d2 Write a program that imports the database from UD.txt, your program can search for users’ password....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT