Description
Military time uses 24 hours for the entire day instead of 12 for am/pm separately. Military time is a 4 digit (base-10) integer with the following rules:
The first two digits show the hour (between 00 and 23) and
The last two digits show the minutes (between 00 and 59)
There is no colon separating hours from minutes.
Military time starts at 0000 in the morning and counts up
When we get to the afternoon, we use 1300 for 1:00 PM and 2300 for 11:00 PM.
When we get to midnight, the hour is 00 (not 24).
TASK: Write a program that reads two times in military format and prints the number of hours and minutes between the two times (See example below).
NOTE: Your program should consider the difference between the times IN THE SAME DAY. For example: The time difference between 2359 and 0000 is 23 hours and 1 minute (NOT 1 minute).
Detailed Requirements
• Compose a written document (MS Word Document) describing your algorithm, feel free include a diagram if you like
• The program should prompt for two times separately, then print the duration of time between (see sample output below).
• The program should check the input for the correct military time format:
. Make sure the hours are between 00 and 23.
. Make sure the minutes are between 00 and 59
. If the validity check fails, it should print an appropriate error and prompt again.
• Your program should use io manipulators to produce military time with leading zeroes. e.g. 9 am should be printed 0900 (not 900).
• More points will be awarded to an implementation that can produce an accurate result regardless of the order of the inputs.
• Do not produce runtime errors that abruptly end your program (crash)
• Include descriptive comments, neat indentation, proper spacing for good readability, and appropriate and consistently named variables.
• Program source should have a comment block at the top with the student name, section, and description of your program.
Please enter a time: 1sykdf
Military Tine Format Required: Bad input, try again.
Please enter a time: 2580
Military Tine Format Required: Hours must be between 2 and 23, try again
Please enter a time: 2365
Military Tine Format Required: Minutes must be between me and 59, try again
Please enter a time: 0900 First time 0900 accepted.
Please enter a time: jdkjs
Military Time Forest Required: Bad input, try again.
Please enter a time: 39573
Military Tine Format Required: Hours must be between 28 and 23, try again
Please enter a time: 1799
Military Tine Format Required: Minutes must be between me and 59, try again
Please enter a time: 1730 Second time: 1738 accepted.
Time difference between 1988 and 1732 ts 8 hours and 30 minutes Dismissed solder!
Note! When I change the order of the time inputs. I get the same result!

Answers

Answer 1

Answer:

from datetime import time, datetime, timedelta, date

for _ in iter(list, 0):

   t1 = input("Please enter time one: ")

   t2 = input("Please enter time two: ")

   if t1.isdigit() == True and (int(t1[:2])<=23 and int(t1[2:]) <= 59)\

       and t2.isdigit() == True and (int(t2[:2])<= 23 and int(t2[2:])<=59):

       time_1 = time(hour=int(t1[:2]), minute=int(t1[2:]))

       time_2 = time(hour= int(t2[:2]), minute=int(t2[2:]))

       if time_1 > time_2:

           diff = datetime. combine (date. today( ), time_1) - datetime. combine(date. today ( ), time_2)

       else:

           diff = datetime. combine (date. today( ), time_2) -datetime. combine(date. today ( ), time_1)

       diff_list = str(diff).split(":")

       del diff_list[2]

       diff_t = "". join (diff_list)

       print(diff_t)

       break        

   if t1.isdigit() == False or t2.isdigit() == False:

       print("Military Time Forest Required: Bad input, try again.")

       continue

   elif int(t1[:2])> 23 or int(t2[:2])> 23:

       print("Military Tine Format Required: Hours must be between 00 and 23, try again")

       continue

   elif int(t1[2:])> 59 or int(t2[2:])> 59:

       print("Military Tine Format Required: Minutes must be between me and 59, try again")

       continue

Explanation:

The python Datetime package is used to manipulate date and time, creating immutable Datetime objects from the various python data types like integer and string. The block of code above is a conditional for-loop statement that gets two user time value inputs and prints out the difference as a string in Military forest time format.


Related Questions

Which of the statements below describe how to print a document?

Answers

Is there supposed to be a picture? We can’t see the options.

If we ignore the audio data in a video file, a video file is just a collection of many individual frames (i.e., images). What is the main reason that a video file can achieve a much higher compression ratio than a file that contains a single image file?

Answers

Answer:

It is compressing the video file to make it smaller, but doing so without actually losing any quality

Explanation:

The main reason for a video file that can achieve a much higher compression ratio than a file that contains a single image file is that it can reduce the size of the file without affecting its quality.

What is Video compression?

Video compression may be defined as a type of methodology that is significantly utilized in order to decline the size of a video file or alter the formatting of the video without compromising its quality.

The process of compression effectively permits you to reduce the number of storage resources that are needed to store videos and save costs. The importance of video compression includes smaller overall file sizes.

Therefore, the main reason for a video file that can achieve a much higher compression ratio than a file that contains a single image file is that it can reduce the size of the file without affecting its quality.

To learn more about Video compression, refer to the link:

https://brainly.com/question/28078112

#SPJ2

identify and explain 3 methods of automatically formatting documents​

Answers

Answer:

Three common automatic formatting for documents are...

Margin justification- where text is aligned to both the left and right margin- producing a neat page

Paragraph justification- where paragraphs are not split as they go over the page- but are moved to the next page in one piece.

Tabular justification- where text is indented or aligned at a 'tab stop'. - to emphasise a paragraph.

The 3 methods used in Microsoft word to auto format are; Margin Justification, Tabular Justification, Paragraph Justification

What is formatting in Microsoft Word?

In Microsoft word, there are different ways of formatting a text and they are;

Margin justification; This is a type of formatting where all the selected text are aligned to either the left or right margin as you go to a new page as dictated by the user.

Paragraph justification; This a type of auto formatting where paragraphs are not split as they go to a new page but simply continue from where they left off.

Tabular justification; This is a type that the text is indented or aligned at a 'tab stop' to possibly show a paragraph.

Read more about Formatting in Microsoft Word at: https://brainly.com/question/25813601

What is also known as a visual aid in a presentation?
A. background
B. animation
C. review
D. slide
E. template

Answers

Visual aids are defined as charts, pictures or images that help to make a point or enhance a presentation, so I would say B. animation.

Hope this helps!!

Answer:

it is d slide

Explanation:

C++ "Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the sequence. Create a for loop that compares the two strings starting from index 0. For each match, add one point to userScore. Upon a mismatch, exit the loop using a break statement. Assume simonPattern and userPattern are always the same length.
Ex: The following patterns yield a userScore of 4:
Ex: The following patterns yield a userScore of 9:
simonPattern: RRGBRYYBGY
userPattern: RRGBBRYBGY
Result: Can't get test 2 to occur when userScore is 9
Testing: RRGBRYYBGY/RRGBBRYBGY
Your value: 4
Testing: RRRRRRRRRR/RRRRRRRRRY
Expected value: 9
Your value: 4
Tests aborted.

Answers

Answer:

In C++:

#include <iostream>

using namespace std;

int main(){

   int userScore = 0;

   string simonPattern, userPattern;

   cout<<"Simon Pattern: ";    cin>>simonPattern;

   cout<<"User Pattern: ";    cin>>userPattern;

   for (int i =0; i < simonPattern.length();i++){

       if(simonPattern[i]== userPattern[i]){

           userScore++;        }

       else{            break;        }

   }

   cout<<"Your value: "<<userScore;

   return 0;

}

Explanation:

This initializes user score to 0

   int userScore = 0;

This declares simonPattern and userPattern as string

   string simonPattern, userPattern;

This gets input for simonPattern

   cout<<"Simon Pattern: ";    cin>>simonPattern;

This gets input for userPattern

   cout<<"User Pattern: ";    cin>>userPattern;

This iterates through each string

   for (int i =0; i < simonPattern.length();i++){

This checks for matching characters

       if(simonPattern[i]== userPattern[i]){

           userScore++;        }

This breaks the loop, if the characters mismatch

       else{            break;        }

   }

This prints the number of consecutive matches

   cout<<"Your value: "<<userScore;

Other Questions
Miguel felt excited as he walked into the circus acrobatics class. He was good at sports, but he'd never tried anything like this before. Now Miguel watched as the teacher stepped onto the mat and demonstrated a flip. With spotters helping, Miguel attempted the same movements, but his flip spun a little sideways. He didn't let that stop him. Miguel kept practicing, and by the end of the session his flip was much improved.How do Miguel's actions reveal the theme of the story?Question 1 options:They show it is possible to overcome fear of new things.They show it is possible to succeed through determination.They warn against being overly confident of your abilities. HELP!!Which of the following statements is TRUE if angle 4 has a measure of 127? URGENT!!!!Find Perimeter of the square with the side 15 in.Use formula P=4s100 in60 in225 in30 in What will a balloon do to a cloth if its negatively charged Ginas teacher asked her to write a reflection about Dr. Kings I Have a Dream speech. What should Gina write about?She should write an historic essay about the time in which the speech was written.She should write a fictional essay as if she were a witness to Dr. Kings speech.She should write an informational essay that identifies key details of the speech.She should write a response to the speech telling what it means to her personally. PLS I NEED HELP QUICKLY Simplify the radical expressions[tex]x^{4}[/tex][tex]2x^{-3}[/tex][tex]6^{-2}[/tex][tex](3k^{2} )^{2\3}[/tex]Thanks!, please don't use me for points! She finally became even more violent in her opposition than her husband himself. She was not satisfied with simply doing as well as he had commanded; she seemed anxious to do better. In the above sentence, the word commanded comes from a Latin root word that means to A callB trustC joinD order Determine the slope of the line whose equation is 2x-3y=5 Felicia and gabriella are on the hamilton middle school basketball team. The box plots show the number of points they scored in 8 basketball games. Write all the factors of S 35. Use commas to senarate them Can somebody help me with this math question, all you have to do is answer the equation, then it's described, and then it draw it out I'll give you 100 points and a Brainliest write a chitar varnan for this image in punjabi Which measurement is the same length as 1 meter The cost of 3 quarts of milk is $6.75. How many quarts can you buy with $20.25? Please help ASAP! ILL MARK BRAINLIEST IF CORRECT PLEASE! IF NEEDED USE THE SECOND IMAGE ATTACHED Find the 11th term of the geometric sequence 6, -18, 54, Answer this correctly Ill give brainalist + 10 points Somebody help ASAP hurry she really thought. i added her but she ain't saying nothing