Question
Intro to Functions, only did pre defined and defined functions so far so don't make it too advanced Write a program that calculates the elapsed
Intro to Functions, only did pre defined and defined functions so far so don't make it too advanced
Write a program that calculates the elapsed time in minutes between a start time and an end time.
The times will be expressed as integers on a 24-hour clock (use military time).
Include two functions:A function that returns a Boolean value of true if the ending time is greater than the beginning time and a value of false if the ending time is less than the beginning time.
Use this function to error check the input.
If the function returns a true to main then calculate the elapsed time.
If the function returns a false then print out an error message stating that the beginning time must be less than the ending time.
A function that calculates the elapsed time in minutes only between a start time and an end time.
The times will be expressed as integers on a 24-hour clock (use military time). This function must convert them and compute the lapsed time.
The function will take two times as input and return the elapsed time through the function name.
The elapsed time will be in minutes. For example, if the beginning time is 330 (3:30 am) and the ending time is 1900 (7:00 pm) then the elapsed time is 930 minutes.
Be sure to include the prologue information.
Be sure to include the initial and refined algorithms for the main function.
To express the time in military:
Only use times on the hour or half hour.
You need to only deal with end times occurring later on the same day as the start time. For example, the ending time must be greater than the beginning time.
Examples of how times will be represented are as follows:
Midnight will be represented as 0.
1:00 am will be represented as 100.
10:00 am will be represented as 1000.
12 noon will be represented as 1200.
3:30 pm will be represented as 1530.
Have the User enter the time without a colon. For example, 8:30 pm will be entered as 2030.
Use a While loop to allow the User to run the program more than once. Use a sentinel value of Y and prompt the User to enter a Y if they wish to continue.
HINT: Its easy to figure out the number of minutes when both the ending and beginning times are on the hour like 7:00 pm. It gets tricky when you have a time on the half hour like 3:30 am. You will need to strip away the 30 minutes from 3:30 am first.
Remember that the difference between the times must be computed in minutes. So if the user enters 330 and 1900, you first compute the number of hours (which is 15 hours) and multiply this by 60 for total minutes. You then add those extra 30 minutes because the first time is 330.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started