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

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 18:00
What is stored in str after the following code executes? string str = "computer science"; int i = 0; while (i < 8) { if (str.indexof("m") < i) { str = str.substring(0, 2) + str; } i += 2; } computer science cocomputer science cococomputer science cocococomputer science computer scienceco
Answers: 3
question
Computers and Technology, 22.06.2019 06:30
Exchanging which type of data uses the least bandwidth? music photographs video voice bandwidth- the amount of data that can be moved between two points in a set time period
Answers: 1
question
Computers and Technology, 22.06.2019 17:00
What allows you to create a wireless connection among your smart devices
Answers: 2
question
Computers and Technology, 23.06.2019 14:30
Norder to receive financial aid at his vocational school, mario must fill out the fafsa. the fafsa is a form that must be completed to determine . in order to complete a fafsa, you must submit . the fafsa can students obtain
Answers: 2
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
question
English, 29.04.2021 17:20