Answer:
// Program is written in Java Programming Language
// Comments are used for explanatory purpose
// Program starts here
public static String getTimeName(int hours, int minutes) {
// Check for valid time
 if ((hours >= 1 && hours <= 12) && (minutes >= 0 && minutes <= 59)) {
// Create an array to hold valid minutes in English
 String validminutes[] = {
 "", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen", "Twenty", "Twenty one", "Twenty two", "Twenty three", "Twenty four", "Twenty five", "Twenty six", "Twenty seven", "Twenty eight", "Twenty nine" };
 String validtime;
// Start Conversion
 if (hours == 12){ // Set time to be One
 validtime = validminutes[1];}
 else{ // Set time to be ahead by one hour
 validtime = validminutes[hours + 1]; }
// Check for minutes
 if (minutes == 0){ // Replace 0 with O' Clock
 System.out.println(validminutes[hours] + "O' Clock");}
 else if (minutes == 15){// Replace with quarter past
 System.out.println("Quarter past " + validminutes[hours]);}
 else if (minutes == 30){// Replace with half past
 System.out.println("Half past" + validminutes[hours]);}
 else if (minutes == 45){// Replace with quarter to
 System.out.println("Quarter to" + a);}
 else if (minutes < 30){ // for other minutes between 1-29
 System.out.println(validminutes[minutes] + " " + "past" + validminutes[hours]);}
 else{ // Other minutes
 System.out.println(hour_mint[60 - minutes] + " " + "to " +validtime);}
 } 
// End of Valid Time
else { // Invalid Tine
 System.out.println("Time not valid ");
 }
}
// End of Program