Define a function SetTime, with int parameters hoursVal and minutesVal, that returns a struct of type TimeHrMin. The function should assign TimeHrMin's data member numHours with hoursVal and numMinutes with minutesVal

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter11: Introduction To Classes
Section11.4: A Case Study: Constructing A Date Class
Problem 9E
icon
Related questions
Question

Define a function SetTime, with int parameters hoursVal and minutesVal, that returns a struct of type TimeHrMin. The function should assign TimeHrMin's data member numHours with hoursVal and numMinutes with minutesVal.

Only lines 8-10 can be affected, the rest of the program cannot be changed.

Define a function SetTime, with int parameters hoursVal and minutesVal, that returns a struct of type TimeHrMin. The function
should assign TimeHrMin's data member numHours with hoursVal and numMinutes with minutesVal.
1 #include <iostream>
2 using namespace std;
3
4 struct TimeHrMin {
int numHours;
int numMinutes;
6.
7 };
8
9 /* Your code goes here */
10
11 int main() {
TimeHrMin lateBy;
int hoursVal;
int minutesVal;
12
13
14
15
16
cin >> hoursVal >> minutesVal;
17
18
lateBy
SetTime(hoursVal,
minutesVal);
19
20
cout << "We met
<« lateBy.numHours << ":" << lateBy.numMinutes <<
hours ago." << endl;
21
22
return 0;
23 }
Transcribed Image Text:Define a function SetTime, with int parameters hoursVal and minutesVal, that returns a struct of type TimeHrMin. The function should assign TimeHrMin's data member numHours with hoursVal and numMinutes with minutesVal. 1 #include <iostream> 2 using namespace std; 3 4 struct TimeHrMin { int numHours; int numMinutes; 6. 7 }; 8 9 /* Your code goes here */ 10 11 int main() { TimeHrMin lateBy; int hoursVal; int minutesVal; 12 13 14 15 16 cin >> hoursVal >> minutesVal; 17 18 lateBy SetTime(hoursVal, minutesVal); 19 20 cout << "We met <« lateBy.numHours << ":" << lateBy.numMinutes << hours ago." << endl; 21 22 return 0; 23 }
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr