Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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 included

Explanation / 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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote