Response:
// This program utilizes the Java Programming Language
// Comments included for clarification
// Program begins here
public static String getTimeName(int hours, int minutes) {
// Verify the time is valid
if ((hours >= 1 && hours <= 12) && (minutes >= 0 && minutes <= 59)) {
// Prepare an array for valid minute representations
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;
// Begin Conversion Process
if (hours == 12){ // Convert time to One
validtime = validminutes[1];}
else{ // Adjust time to one hour forward
validtime = validminutes[hours + 1]; }
// Determine minutes
if (minutes == 0){ // Output O' Clock for 0
System.out.println(validminutes[hours] + "O' Clock");}
else if (minutes == 15){// Output quarter past
System.out.println("Quarter past " + validminutes[hours]);}
else if (minutes == 30){// Output half past
System.out.println("Half past" + validminutes[hours]);}
else if (minutes == 45){// Output quarter to
System.out.println("Quarter to" + a);}
else if (minutes < 30){ // Handle minutes ranging from 1-29
System.out.println(validminutes[minutes] + " " + "past" + validminutes[hours]);}
else{ // Manage other minute cases
System.out.println(hour_mint[60 - minutes] + " " + "to " +validtime);}
}
// Closure of Valid Time Check
else { // Time deemed invalid
System.out.println("Time not valid ");
}
}
// End of the Program