Question: Part 3: Time Program Complete the code for the provided time class Like the elapsed time homework, it will keep track of the time using



Part 3: Time Program Complete the code for the provided time class Like the elapsed time homework, it will keep track of the time using military time (hours, minutes and seconds). In other words, the hour value ranges from 0-23, where 0-11 represents a time before noon. Minute and second values range from 0 to 59 As an example, you have been given a static getTime24 method that creates a String in the format "hh:mm:ss". It uses the String class' format method to build the String. The format ethod uses the same ntax as the printf method Static Methods Begin by writing the static methods: private static boolean isValid (int h24, int m24, int s24) returns true if the given parameters are valid hours, minutes, and seconds in 24 hour time private static boolean isValid(int h12, int m12, int s12, boolean isAM) returns true if the given parameters are valid hours, minutes, and seconds in 12 hour time . public static String getTime12 (int h24, int m24, int s24) a static method that converts the time from 24 hour time to a String in the format "h:mm:ss AM "hh:mm:ss AM","h:mm:ss PM", or "hh:mm:ss PM". For example 0, 0,0 converts to the String "12:00:00 AM" 7, 30, 5 converts to the String "7:30:05 AM" 9,0,0 converts to the String "9:00:00 AM" 12, 0, 0 converts to the String "12:00:00 PM" 17, 0, 0 converts to the String "5:00:00 PM Don't forget to look at my getTime24 method for how to format the text correctly using the String format method. You should also write the private helper methods // two methods to help convert from 24 hours time to 12 hour time private static int convertToStandard (int h24) private static boolean isAM (int h24) // one method to help convert from 12 hour time to 24 hour time: . private static int convertToMilitary (int h12, boolean isAM) Non-Static Methods Part 3: Time Program Complete the code for the provided time class Like the elapsed time homework, it will keep track of the time using military time (hours, minutes and seconds). In other words, the hour value ranges from 0-23, where 0-11 represents a time before noon. Minute and second values range from 0 to 59 As an example, you have been given a static getTime24 method that creates a String in the format "hh:mm:ss". It uses the String class' format method to build the String. The format ethod uses the same ntax as the printf method Static Methods Begin by writing the static methods: private static boolean isValid (int h24, int m24, int s24) returns true if the given parameters are valid hours, minutes, and seconds in 24 hour time private static boolean isValid(int h12, int m12, int s12, boolean isAM) returns true if the given parameters are valid hours, minutes, and seconds in 12 hour time . public static String getTime12 (int h24, int m24, int s24) a static method that converts the time from 24 hour time to a String in the format "h:mm:ss AM "hh:mm:ss AM","h:mm:ss PM", or "hh:mm:ss PM". For example 0, 0,0 converts to the String "12:00:00 AM" 7, 30, 5 converts to the String "7:30:05 AM" 9,0,0 converts to the String "9:00:00 AM" 12, 0, 0 converts to the String "12:00:00 PM" 17, 0, 0 converts to the String "5:00:00 PM Don't forget to look at my getTime24 method for how to format the text correctly using the String format method. You should also write the private helper methods // two methods to help convert from 24 hours time to 12 hour time private static int convertToStandard (int h24) private static boolean isAM (int h24) // one method to help convert from 12 hour time to 24 hour time: . private static int convertToMilitary (int h12, boolean isAM) Non-Static Methods
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
