Introduction to Object-Oriented Programming
Help me study for my Engineering class. I’m stuck and don’t understand.
Write a program that prompts the user to enter the time in the format hours:minutes AM/PM then calculates the number of hours (including portions of an hour) that have elapsed since the start of the day. Write to the console the number of hours, showing exactly two decimal places. Your program should display the correct number of hours elapsed for any valid time input. If the time input is invalid, your program should display an error message. Assume that midnight is represented by 12:00 AM, and noon by 12:00 PM.
Submit your source code in a file named ParseTime.java!
Sample input and output (inputs preceded by >):
Enter the time in the format hours:minutes AM/PM, e.g. 7:06 PM > 7:06 PM
19.10 hours have elapsed from start of day
Enter the time in the format hours:minutes AM/PM, e.g. 7:06 PM > 11:66 AM
Invalid time format