Question: Need to create a program for showing the correct time of day in seconds after midnight, using basic java, primative data, definite loops, parameters and

Need to create a program for showing the correct time of day in seconds after midnight, using basic java, primative data, definite loops, parameters and objects, conditional execution, and program logic and indefinite loops:

secondsAfterMidnight

Input: String that represents time of day

Returns: integer number of seconds after midnight (return -1 if String is not valid time of day)

General time of day format HH:MM:SS(AM/PM)

// Examples:

// Input String Return Value

// "12:34:09AM" 2049

// "12:00:00PM" 43200 (common noon)

// "12:00:02am" 2 (AM/PM case insensitive)

// "3:03:03Pm" 54183 (two digit MM and SS required)

// "7:11:03A" -1

// "7:11:3AM" -1

// "7:91:73PM" -1

// "23:45:12" -1 (do not allow 24 hour clock format)

public static int secondsAfterMidnight(String) {

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!