Question: Define a private helper function called ConvertToMinutes() that converts the data member hours to minutes and returns an integer. Ex: If the input is 540,
Define a private helper function called ConvertToMinutes() that converts the data member hours to minutes and returns an integer.
Ex: If the input is 540, then the output is:
32400 minutes
Note: The equation to convert from hours to minutes is: minutes = hours * 60
#include
class Time { public: void SetHours(int timeHours); int GetHours() const; void PrintInMinutes(); private: int hours; int ConvertToMinutes(); };
void Time::SetHours(int timeHours) { hours = timeHours; }
int Time::GetHours() const { return hours; }
/* Your code goes here */
void Time::PrintInMinutes() { cout << fixed << setprecision(1) << ConvertToMinutes() << " minutes" << endl; }
int main() { Time time1; int inputHours;
cin >> inputHours; time1.SetHours(inputHours);
time1.PrintInMinutes();
return 0; }
c++ please please make it correct
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
