Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Python Program with main funcions Arrival Time Estimator Create a program that c

ID: 3813944 • Letter: P

Question

Python Program with main funcions

Arrival Time Estimator
Create a program that calculates the estimated hours and minutes for a trip. This should include an estimated date/time of departure and an estimated date/time of arrival

Specifications
For the date/time of departure and arrival, the program should use the YYYY-MM-DD format for dates and the HH:MM AM/PM format for times.
For the miles and miles per hour, the program should only accept integer entries like 200 and 65.

Assume that the user will enter valid data.

Add validation (error checking) and exception handling for all user entries. In other words, do not assume the user will enter valid data

Explanation / Answer

DATE AND TIME FUNDAMENTALS

At their cores, dates and times in Excel are simply numbers formatted to look like dates and times. Dates are whole numbers
ranging from 1 to 2,948,565, with “1” representing January 1, 1900, “2” representing January 2, 1900, “3” representing
January 3, 1900, etc. As information, “2,958,465” represents December 31, 9999. As you enter data in Excel that resemble
dates and times – such as entering “3/29/12” in a cell – Excel “guesses” that you really want to enter a number and format
it to look like a date or time entry and updates your entry in real-time to reflect its supposition. Of course, you can
also enter the appropriate number for the date or time value and manually apply the desired date or time format to the
cell.

While many Excel users understand the whole number premise of dates, some tend to struggle with times. Times are decimal
values greater than or equal to zero, but less than 1, that are used to identify what percentage of the 24-hour clock has
elapsed. For example, “0” represents 12:00 a.m. (midnight), “0.25” represents 6:00 a.m., “0.50” represents 12:00 p.m.
(noon), and “0.75” represents 6:00 p.m. Given that one hour represents 4.166% (1/24) of a full day, each of the preceding
examples should come a bit more in focus for those who have not previously worked with times – for instance, 6 hours times 4.166% = 0.25, the decimal value for 6:00 a.m.

CALCULATIONS BASED ON DATES AND TIMES

Given the above, to calculate the amount of time that passes between, say, 9:12 a.m. and 4:48 p.m., you only need to
subtract the starting time from the ending time. As shown in Figure 1, with the starting time in cell B2 and the ending
time in cell B3, a simple formula of =B3-B2 in cell B4 is all that is necessary to calculate the amount of elapsed time.

CALCULATING THE AMOUNT OF TIME ELAPSED

To present the result in terms of hours and minutes, change the cell format to h:mm, and cell B4 updates to 7:36, as shown


DISPLAYING ELAPSED TIME WITH PROPER CELL FORMAT

To measure total time hours elapsed when that amount of time exceeds 24 hours, you must use a time format that includes
brackets, such as [h]:mm. For instance, suppose you needed to measure the total amount of time (expressed in hours and
minutes) that elapsed from the time a loaded delivery truck with tandem drivers left your warehouse at noon on May 6, 2012, until the time the truck arrived at a customer location on May 8, 2012, at 8:45 a.m. If you construct a worksheet similar to that shown in Figure 3 and enter a formula that subtracts the departure time from the arrival time with a “General” or “Number” format applied to the result, Excel presents the result in terms of days.

ATTEMPTING TO MEASURE TOTAL HOURS ELAPSED

As shown in Figure 4, to present the result in terms of hours and minutes, change the cell format to [h]:mm, and the
results cell updates to 44:45, indicating that the trip consumed 44 hours and 45 minutes.

PRESENTING TIME ELAPSED IN TERMS OF HOURS AND MINUTES INSTEAD OF DAYS


SUMMARY

Because dates and times are simply numbers formatted to look like dates and times, you can perform mathematical operations
on dates and times the same way you perform mathematical operations on any other number. Based on this, to calculate the
amount of time elapsed between a starting point and an ending point, just subtract one from the other.