You are viewing a single comment's thread. Return to all comments →
Single line to check it all :D
String[] words = {"o' clock", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "quarter", "sixteen", "seventeen", "eighteen", "nineteen", "twenty", "half"}; Scanner in = new Scanner(System.in); int h = in.nextInt(); int m = in.nextInt();
System.out.println((m==0)?(words[h] + " " + words[m]):((m < 30 && m != 15)?(((m<=20)?words[m]:("twenty " + words[m%20])) + ((m==1)?" minute":" minutes") + " past " + words[h]):((m == 30 || m==15)?(((m==30)?words[21]:words[m]) + " past " + words[h]):((((60-m)<=20)?words[60-m]:("twenty " + words[(60-m)%20])) + (((60-m)==15)?"":(((60-m)==1)?" minute":" minutes")) + " to " + words[h+1]))));
Seems like cookies are disabled on this browser, please enable them to open this website
The Time in Words
You are viewing a single comment's thread. Return to all comments →
Single line to check it all :D
String[] words = {"o' clock", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "quarter", "sixteen", "seventeen", "eighteen", "nineteen", "twenty", "half"}; Scanner in = new Scanner(System.in); int h = in.nextInt(); int m = in.nextInt();