subject
Computers and Technology, 11.02.2020 23:16 akp24

In Lab 03 we wrote a program to calculate the number of seconds since midnight. Modify the program by adding error checking loops. Hour must be a number from 1 to 12. Minute and second must be numbers from 0 to 59. Also check whether "AM" or "PM" is entered. Every time an invalid value is entered, display an error message and ask the user to re-enter a valid value immediately.
The following is an example:
Enter hour: 0
Hour must be from 1 to 12.
Enter hour: 13
Hour must be from 1 to 12.
Enter hour: 12
Enter minute: -1
Minute must be from 0 to 59.
Enter minute: 60
Minute must be from 0 to 59.
Enter minute: 14
Enter second: -1
Second must be from 0 to 59.
Enter second: 60
Second must be from 0 to 59.
Enter second: 47
Enter AM or PM: FM
Please enter AM or PM
Enter AM or PM: PM
Seconds since midnight: 44087
Save your Python program in a file named Lab 04P2.py. Submit the file to Blackboard for credit.

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 15:10, cathyjuan
What role did women fill during world war ii?
Answers: 1
image
Computers and Technology, 24.06.2019 02:20, Jonny13Diaz
The first time a user launches the powerpoint program, which view is shown allowing the user to access recent presentations or create new presentations based on templates?
Answers: 1
image
Computers and Technology, 24.06.2019 08:20, bob4059
Evaluate the scenario below and indicate how to handle the matter appropriately. situation: michael received an e-mail from what he thought was his doctor’s office, requesting his social security number. since he had just been in to see his doctor last week, he replied to the e-mail with his social security number.
Answers: 2
image
Computers and Technology, 24.06.2019 18:30, kristine2424
Is a type of bullying that takes place when a person intentionally posts negative information about another that is not true
Answers: 1
You know the right answer?
In Lab 03 we wrote a program to calculate the number of seconds since midnight. Modify the program b...

Questions in other subjects:

Konu
Mathematics, 20.03.2021 01:00
Konu
Mathematics, 20.03.2021 01:00
Konu
Mathematics, 20.03.2021 01:00
Konu
Mathematics, 20.03.2021 01:00