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: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

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
  • I) will create a rudimentary (and highly insecure) database for the storage of only the user...

    I) will create a rudimentary (and highly insecure) database for the storage of only the user generated identities. This program will have the following behaviors: (line break, 11 pt) ) - Prior to prompting for a new username, the existing list of usernames should be read and loaded to an array. 1 ) Read the list from "users.txt", a prompt is not necessary. Do not change this data file name "users.txt". 2 ) The existing list of usernames should be...

  • 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...

  • Lab: User login system (python) Create a user login system. Your code should do the following:...

    Lab: User login system (python) Create a user login system. Your code should do the following: 1.Load your user database from “UD.txt” (USE THE EXACT FILE NAME, file is given in the folder) 2.Display “Login or create a new user? Select L to login, select C to create new user.” 3. If wrong selection is entered, take the user back to step 2. 4. If the user entered “L”, display “Please enter your user name and hit enter” 5. Check...

  • 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...

  • please use Python You are to create a program that generates an email addresses. The format...

    please use Python You are to create a program that generates an email addresses. The format is as follows: firstname.lastname@domain.topleveldomain (maximum 60 characters) example (aaa.bbb@ccc.ddd) please use any number of variables and types that you wish. The only requirement is that you ask the user one at a time for first name, last name, domain and TLD (top level domain), use that to generate the email address string. The maximum size of the created email address string is 60. If...

  • 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...

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