Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your time machine is capable of going forward in time up to 24 hours. The machine is configured to jump ahead in minutes. To enter

Your time machine is capable of going forward in time up to 24 hours. The machine is configured to jump ahead in minutes. To enter the proper number of minutes into your machine, you would like a program that can take a start time (in hours, minutes, and a Boolean indicating AM or PM) and a future time (in hours, minutes, and a Boolean indicating AM or PM) and calculate the difference in minutes between the start and future time.

A time specified in your program with three variables:

int hours, minutes;

bool isAM;

For example, to represent 11:50 PM, you would store:

hours = 11

minutes=50

isAm = false

This means that you need six variables to store a start and future time.

Write a program that allows the user to enter a start time and a future time. Include a function named computeDifference that takes the six variables as parameters that represent the start time and future time. Your function should return, as an int, the time difference in minutes. For example, given a start time of 11:59 AM and a future time of 12:01 PM, your program should compute 2 minutes as the time difference. Given a start time of 11:59 AM and a future time of 11:58 AM, your program should compute 1439 minutes as the time difference and should display 23 hours and 59 minutes.

You may need AM or PM from the users input by reading in two character values or a string. i.e. a for am and p for pm or "am" or "pm".

ALLOW USER TO CONTINUE TO USE TIME MACHINE UNTIL HE/SHE WISHES TO STOP.

Output should be, example

Enter start time, in the format 'HH:MM xm', where 'xm' is either 'am' or 'pm' for AM or PM: 12:05 am

Enter future time in the format 'HH:MM xm' where 'xm' is either 'am' or 'pm': 12:15 am

There are 10 minutes (0 hours and 10 minutes) between 12:05 AM and 12:15AM.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago