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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started