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

How? This is practice... but I want to use it for a template for something. Lab

ID: 3799433 • Letter: H

Question

How? This is practice... but I want to use it for a template for something. Lab Assignment: (30 points) Part 1) Your program will provide three different options of usernames using the input from the user. You will follow these guidelines: Option 1: lastnamefirstnametttt (where two random digits (1-9)) Kandon ter on 2.15 Option 2: firstnamechar1lastnamett (where tttt last two digits of birth year) option 3: #ttlastnamefirst3charsfirstnamelast3chars (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: 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 S

Explanation / Answer

Code:

import java.util.Random;
import java.util.Scanner;

public class HelloWorld{

public static void main(String []args){

Random rand= new Random();
Scanner scan=new Scanner(System.in);

System.out.println("Enter your firstname:");
String fname=scan.nextLine();

System.out.println("Enter your lastname:");
String lname=scan.nextLine();

System.out.println("Enter your Dateof birth MMDDYY:");
String dob=scan.nextLine();


int n=rand.nextInt(10);

String option1= lname+fname+n;
String option2= fname.substring(0,1)+lname+dob.substring(dob.length()-2);
String option3= lname.length()+ fname.substring(0,3) + lname.substring(0,3);
System.out.println(fname+ " " + lname+ " " + n);
System.out.println("Choose the following 3 options");
System.out.println(option1+ " " +option2+ " " + option3);
int opt=scan.nextInt();

if(opt==1)
System.out.println("Your desired email is : " + option1 + "cisco.com");
else if (opt==2)
System.out.println("Your desired email is : " + option2 + "cisco.com");
else if(opt==3)
System.out.println("Your desired email is : " + option3 + "cisco.com");


}
}

Output:

Enter your firstname:                                                                                                                                    

Randy                                                                                                                                                    

Enter your lastname:                                                                                                                                     

Williams                                                                                                                                                 

Enter your Dateof birth MMDDYY:                                                                                                                          

180867                                                                                                                                                   

Randy Williams 4                                                                                                                                         

Choose the following 3 options                                                                                                                           

WilliamsRandy4                                                                                                                                           

RWilliams67                                                                                                                                              

8RanWil                                                                                                                                                  

2                                                                                                                                                        

Your desired email is : RWilliams67cisco.com

Note:

Chegg answer window doesn't allow me to use [at]cisco.com. Please include those in your code while executing.

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