Question: This is what the output should look like. I've been given main but nothing else. I need help with the supporting .cpp files for each

This is what the output should look like.This is what the output should look like.I've been given main butI've been given main but nothing else. I need help with the supporting .cpp files for each of the .h files. I have three .h files(invalidHr, invalidMin and invalidSec)

Write a program that prompts the user to enter time in 12-hour notation.

The program then outputs the time in 24-hour notation. Your program

must contain three exception classes: invalidHr, invalidMin, and

invalidSec. If the user enters an invalid value for hours, then the program

should throw and catch an invalidHr object. Similar conventions for the invalid values of minutes and seconds.

 Given: #include #include #include "invalidHr.h" #include "invalidMin.h" #include "invalidSec.h" using namespace std; int getHours(); int getMinutes(); int getSeconds(); void print24HourTime(int hr, int min, int sec, string str); int main () { int hours; int minutes; int seconds; string str; hours = getHours(); minutes = getMinutes(); seconds = getSeconds(); cout > str; cout > hr; cout  12) throw invalidHr(); done = true; } catch (invalidHr hrObj) { cout > min; cout  59) throw invalidMin(); done = true; } catch (invalidMin minObj) { cout > sec; cout  59) throw invalidSec(); done = true; } catch (invalidSec secObj) { cout  

#ifndef H_invalidHr

#define H_invalidHr

#include "invalidMin.h"

#include "invalidSec.h"

#include

#include

using namespace std;

class invalidHr

{

public:

invalidHr()

{

message = "The value of hr must be between 0 and 12.";

}

invalidHr(string str)

{

message = str + "Invalid input.";

}

string what()

{

return message;

}

public:

string message;

};

#endif

#ifndef H_invalidMin

#define H_invalidMin

#include

#include

using namespace std;

class invalidMin

{

public:

public:

invalidMin()

{

message = "Enter minutes: ";

}

invalidMin(string str)

{

message = str + "Invalid input.";

}

string what()

{

return message;

}

public:

string message;

};

#endif

#ifndef H_invalidSec

#define H_invalidSec

#include

#include

using namespace std;

class invalidSec

{

public:

invalidSec()

{

message = "Enter seconds: ";

}

invalidSec(string str)

{

message = str + "Invalid input.";

}

string what()

{

return message;

}

public:

string message;

};

#endif

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!