100% found this document useful (1 vote)
1K views3 pages

Ug

Userid

Uploaded by

Rakesh Lepakshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
100% found this document useful (1 vote)
1K views3 pages

Ug

Userid

Uploaded by

Rakesh Lepakshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 3
Question User ID Generation: Joseph's team has been assigned the task of creating user-ids for all participants of an online gaming competition. Joseph has designed a process for generating the user -id using the participant's First_Name, Last_Name, PIN code and a number N. The process defined by Joseph is as below — ‘Step1 - Compare the lengths of First_Name and Last_Name of the partcipant. The one that is shorter will be called “Smaller Name” and the one that is longer will be called the “Longer Name". if both First_Name and Last_Name are of equal Length. then the name that appears earlier in alphabetical order will be called “Smaller Name” and the name that appears later in alphabetical order will be called the “Longer Name” Step? - The user-id should be generated as below — Last Letter of the smaller name + Entire word of the longer name + Digit at position N in the PIN when traversing the PIN from left to right + Digit at position Nin the PIN when traversing the PIN from right to left Steps - Toggle the alphabets of the user-id generated in step-2 Le. upper- case alphabets should become lower-case and lower-case alphabets should become upper-case. Let us see a few examples. Example-1 - if the participant's details are as below - First_Name = Rajiv Last_Name = Roy PIN = 560037 N=6 ‘Step1 - Length of Last_Name is less than the Lenath of First_Name. so the ‘Smaller Name is “Roy” and the Longer Name is “Rajv" ‘Step2 - The user-id will be = Last Letter of the smaller name + Entire word in the longer name + Digit at position N in the PIN when traversing the PIN from left to right + Diatt at position N in the PIN when traversing the PIN from right to left = Last Letter of “Roy’ + Entire word in “Raliv’ + 6th Digit of PIN fromleft + 6th Digit of FIN from right =y+Raiv+745 Therefore, user-id = yRajiv75 ‘Steps - Toggle the alphabets in the user-id. So, user-id = YrAJIV75 Example-2 - If the participant's details are as below - First_Name = Manoj Last_Name = Kumar PIN = 561327 N=2 Stept - Length of First_Name is equal to the Length of Last_Name. Alphabetically, ‘Kumar’ appears earlier than ‘Manoj’ (by comparing alphabetic positions of °k’ and ‘N') so the Smaller Name is “kumar” and the Longer Name. is “Manoj Step2 - The user-id will be = Last Letter of the smaller name + Entire word in the longer name + Digit at position N in the PIN when traversing the PIN from left to right + Digit at postion N in the PIN when traversing the PIN from right to lent = Last Letter of “Kumar” + Entire word in “Manoj + 2nd Digit of PIN from left + 2 4 Digit of PIN from right =1+Manoj +6 +2 ‘Therefore, user-id = rManojé2 ‘Steps - Toggle the alphabets in tne user-id. So, user-ld = RMANOJS2 Example-3 - If the participant's details are as below - First_Name = Kumud Last_Name = Kumar PIN = 561327 N=2 Stept - Length of First_Name is equal to the Length of Last_Name. Alphabetically, ‘Kumar’ appears earlier than Kumud’ (by comparing alphabetic positions of ‘Kum a’ and ‘Kum u’) so the Smaller Name is “Kumar” and the Longer Name is “kumud” ‘Step? - The user-id will be = Last Letter of the smaller name + Entire word in the longer name + Digit at position N in the PIN when traversing the PIN from left to right + Digit at posttion N in the PIN when traversing the PIN from night to left = Last Letter of “Kumar” + Entire word in “Kumuc” + 2nd Digit of PIN from left + 2° Digit of PIN from right =r+Kumud +6 +2 Therefore, user-id = rkumuds2 ‘Step3 - Toggle the alphabets in the user-id. So, user-id = RKUMUDS2 You are part of Joseph's team and he has asked you to write a program (method) to generate the participant's user-id using the above rules. The prototype of the method (function) should be as below — [For Java & C#] String userldGeneration(String inputt, String input2, int inputs, int input) [For ¢ and C++] char‘ useridGeneration(char* input, char* input2, int input3, int input) where, inputt is the First_Name, Inputz Is the Last_Name inputd is the PIN inputa is the number N ‘The method (function) should do the processing as per rules explained above ‘and should return the generated user-id Assumption - For convenience of this assessment question, Let us assume that the value of N (input4) will abvays be less than or equal to the number of digits in the PIN.

You might also like