// Daily Calendar // // public class Program2_v2 { public static String helper(int h, int m, boolean am) { String s = ""; // Add the hours if(h<10) s += " " + h; // add space infront of single digit numbers else s+= h; // no space infront of double digit numbers // Add the minutes if(m==0) s+= ":" + "00"; else s+= ":" + m; // Add a.m./p.m. if(am == true) s+= " a.m."; else s+= " p.m."; return s; } public static void main(String[] args) { // Morning for(int h=9; h<12; h++) for(int m=0; m< 60; m+=15) System.out.println(helper(h, m, true)); // Lunch for(int m=0; m< 60; m+=15) System.out.println(helper(12, m, true)); // Afternoon for(int h=1; h<6; h++) for(int m=0; m< 60; m+=15) System.out.println(helper(h, m, false)); // Handle 6:00 p.m. separately System.out.println(helper(6, 0, false)); } }