Question: Write a program that creates a username based on the user's first and last name. Prompt the user for and read the user's first
Write a program that creates a username based on the user's first and last name. Prompt the user for and read the user's first name and last name separately. Print a string composed of the first letter of the user's first name, followed by the first five characters of the user's last name, followed by a random number in the range 10 to 90 (inclusive). Output the username in all lowercase. You will then create a secret code number using the user's phone number. Prompt the user to enter a phone number, including the dashes. Create a code by taking the last four digits of the phone number, append a random number from 100 to 500 (inclusive) and then append the area code. i.e., if the number is 309-452-6029 with a random number of 422 would give you 6029422309. Finally, replace all O's in the secret code with $, all 8's with the letter B, and all 4's with the letter A: Output the code. You must use String methods to find the correct portions of the number. You must search for the second dash in the phone number to retrieve the last four numbers of the phone number. Sample output(user input in bold): Enter your first name: Susan Enter your second name: Johnson Enter your phone number with dashes-xxx-xxx-xxxx: 309-452-6029 Random number: 89 The username is: sjohns89 Random number: 422 Your secret code is: 6$29A223$9 Remember that the random numbers will generate different values than what is displayed here. Name your program UserSecretCode.java. Make sure your output matches the format above. Input will come from the keyboard using the Scanner class. Output will be displayed on the console
Step by Step Solution
There are 3 Steps involved in it
Heres a Java program named UserSecretCodejava that creates a username based on the users first and l... View full answer
Get step-by-step solutions from verified subject matter experts
