SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Walter Savitch ,julia Lobur
Chapter:
Separate Compilation And Namespaces
Exercise:
Programming Projects
Question:1 | ISBN:9780321531346 | Edition: 7

Question

Add the following member function to the ADT class DigitalTime

defined in Displays 12.1 and 12.2:

This function computes the time interval between two values of type

DigitalTime. One of the values of type DigitalTime is the object that

calls the member function interval_since, and the other value of type

void DigitalTime::interval_since(const DigitalTime& a_previous_time,

int& hours_in_interval, int& minutes_in_interval) const

DigitalTime is given as the first argument. For example, consider the

following code:

DigitalTime current(5, 45), previous(2, 30);

int hours, minutes;

current.interval_since(previous, hours, minutes);

cout << "The time interval between " << previous

<< " and " << current << endl

<< "is " << hours << " hours and "

<< minutes << " minutes.\n";

In a program that uses your revised version of the DigitalTime ADT, this

code should produce the following output:

The time interval between 2:30 and 5:45

is 3 hours and 15 minutes.

Allow the time given by the first argument to be later in the day than the

time of the calling object. In this case, the time given as the first argument

is assumed to be on the previous day. You should also write a program to

test this revised ADT class.

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Sorry the answer is not available at the moment…

If you are able to find the answer, please make sure to post it here. So that your Juniors have smile on their lips and feel happy.

Spread the 'tradition of sharing'.