Last active
March 17, 2020 11:57
-
-
Save arpanpreneur/1ea2d2ba244198335e6a606e8457aeb4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
class Intern { | |
static String getStringValue(int n) { | |
switch (n) { | |
case 1: return "First"; | |
case 2: return "Second"; | |
case 3: return "Third"; | |
case 4: return "Fourth"; | |
case 5: return "Fifth"; | |
case 6: return "Sixth"; | |
case 7: return "Seventh"; | |
case 8: return "Eighth"; | |
case 9: return "Nineth"; | |
case 10: return "Tenth"; | |
case 11: return "Eleventh"; | |
case 12: return "Twelveth"; | |
case 13: return "Thriteenth"; | |
case 14: return "Fourteenth"; | |
case 15: return "Fifteenth"; | |
case 16: return "Sixteenth"; | |
case 17: return "Seventeenth"; | |
case 18: return "Eighteenth"; | |
case 19: return "Nineteenth"; | |
case 20: return "Twentieth"; | |
case 21: return "Twentifirst"; | |
case 22: return "Twentisecond"; | |
case 23: return "Twentythird"; | |
case 24: return "Twentyfourth"; | |
default: return "Janina"; | |
} | |
} | |
public static void main(String args[]) { | |
Scanner sc = new Scanner(System.in); | |
int id = sc.nextInt(); | |
process(id); | |
} | |
static void print(int day, int intern) { | |
System.out.println(getStringValue(intern)+" Intern (Day "+day+")"); | |
} | |
static void process(int id) { | |
int day, intern; | |
if (id % 5000 == 0) { | |
// It is a day One id | |
day = 1; | |
intern = id / 5000; | |
print(day, intern); | |
} else { | |
int x = 1; | |
int diff = id % 5000; | |
int incVal = 2; day = 2; | |
id -= 5000; | |
while (x != diff) { | |
x = x + incVal; | |
incVal++; | |
day++; | |
id -= 5000; | |
} | |
intern = id / 5000; | |
print(day, intern); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment