C++ question Write the code needed to read in a time-of-day in the military (aka
ID: 3595699 • Letter: C
Question
C++ question
Write the code needed to read in a time-of-day in the military (aka 24-hour) format. Show your variables and executable statements. I do NOT want a whole program — just the input code and declarations of variables. The user will be entering the time in 24-hour notation (i.e. 20:40, 20:40:03, etc.) with the seconds being optionally included.
I No Paragraph Write the code needed to read in a time-of-day in military (aka 24-hour) format. Show your variables and executable statements. I do NOT want a whole program -- just the input code and declarations of variables. The user will be entering the time in 24-hour notation (.e 20:40, 20:40:03, etc.) with the seconds being optionally includedExplanation / Answer
Source Code:
#include <iostream>
using namespace std;
class Time {
int hr,min,sec;
public:
void get()
{
cin>>hr>>min>>sec;
}
void display()
{
cout<<hr<<":"<<min<<":"<<sec;
}
};
int main() {
Time time; // Declare Box1 of type Box
cout<<"Enter time ";
time.get();
cout<<"The entered time is ";
time.display();
return 0;
}
Output:
Enter time 2 23 12
The entered time is 2:23:12
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.