Please write in C 4 Time Format In Program 1520 the file Tim

Please write in C++

4. Time Format In Program 15-20, the file Time. h contains a Time class. Design a class called MilTime that is derived from the Time class. The MilTime class should convert time in military (24-hour) format to the standard time format used by the Time class. The class should have the following member variables: milHours: Contains the hour in 24-hour format. For example, 1:00 pm would be stored as 1300 hours, and 4:30 pm would be stored as 1630 hours. milseconds: Contains the seconds in standard format The class should have the following member functions: constructor: The constructor should accept arguments for the hour and seconds, in military format. The time should then be converted to standard time and stored in the hours, min, and sec variables of the Time class. Accepts arguments to be stored in the milHours and milseconds setTime variables. The time should then be converted to standard time and stored in the hours, min, and sec variables of the Time class

Solution

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

/*C++ program to read time in HH:MM:SS format and convert into total seconds.*/

#include <iostream>

#include <iomanip>

using namespace std;

class Time

{

    private:

        int seconds;

        int hh,mm,ss;

    public:

        void getTime(void);

        void convertIntoSeconds(void);

        void displayTime(void);

};

void Time::getTime(void)

{

    cout << \"Enter time:\" << endl;

    cout << \"Hours?   \";          cin >> hh;

    cout << \"Minutes? \";          cin >> mm;

    cout << \"Seconds? \";          cin >> ss;

}

void Time::convertIntoSeconds(void)

{

    seconds = hh*3600 + mm*60 + ss;

}

void Time::displayTime(void)

{

    cout << \"The time is = \" << setw(2) << setfill(\'0\') << hh << \":\"

                             << setw(2) << setfill(\'0\') << mm << \":\"

                             << setw(2) << setfill(\'0\') << ss << endl;

    cout << \"Time in total seconds: \" << seconds;

}

int main()

{

    Time T; //creating objects

    

    T.getTime();

    T.convertIntoSeconds();

    T.displayTime();

    

    return 0;

}

Time clock

// Windows

#ifdef _WIN32

#include <Windows.h>

double get_wall_time(){

    LARGE_INTEGER time,freq;

    if (!QueryPerformanceFrequency(&freq)){

        // Handle error

        return 0;

    }

    if (!QueryPerformanceCounter(&time)){

        // Handle error

        return 0;

    }

    return (double)time.QuadPart / freq.QuadPart;

}

double get_cpu_time(){

    FILETIME a,b,c,d;

    if (GetProcessTimes(GetCurrentProcess(),&a,&b,&c,&d) != 0){

        // Returns total user time.

        // Can be tweaked to include kernel times as well.

        return

            (double)(d.dwLowDateTime |

            ((unsigned long long)d.dwHighDateTime << 32)) * 0.0000001;

    }else{

        // Handle error

        return 0;

    }

}

// Posix/Linux

#else

#include <time.h>

#include <sys/time.h>

double get_wall_time(){

    struct timeval time;

    if (gettimeofday(&time,NULL)){

        // Handle error

        return 0;

    }

    return (double)time.tv_sec + (double)time.tv_usec * .000001;

}

double get_cpu_time(){

    return (double)clock() / CLOCKS_PER_SEC;

}

#endif

Please write in C++ 4. Time Format In Program 15-20, the file Time. h contains a Time class. Design a class called MilTime that is derived from the Time class.
Please write in C++ 4. Time Format In Program 15-20, the file Time. h contains a Time class. Design a class called MilTime that is derived from the Time class.
Please write in C++ 4. Time Format In Program 15-20, the file Time. h contains a Time class. Design a class called MilTime that is derived from the Time class.
Please write in C++ 4. Time Format In Program 15-20, the file Time. h contains a Time class. Design a class called MilTime that is derived from the Time class.
Please write in C++ 4. Time Format In Program 15-20, the file Time. h contains a Time class. Design a class called MilTime that is derived from the Time class.

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site