1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
valina [46]
3 years ago
6

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 should contain three exception classes: InvalidHr, InvalidMin, and InvalidSec. If user enters invalid value for hour, then the program should throw and catch an InvalidHr object. Same applies to the invalid value for minutes and seconds.
Engineering
1 answer:
Juliette [100K]3 years ago
4 0

Answer:

THE CODE FOR THE PROGRAM IS GIVEN BELOW:

#include <iostream>

#include "ConvertTimeHeader.h"

using namespace std;

int main()

{

convertTime convert;

int hr, mn, sc = 0;

 

cout << "Please input hours in 12 hr notation: ";

cin >> hr;

cout << "Please input minutes: ";

cin >> mn;

cout << "Please input seconds: ";

cin >> sc;

 

convert.invalidHr(hr);

convert.invalidMin(mn);

convert.invalidSec(sc);

convert.printMilTime();

 

system("Pause");

 

return 0;  

 

}

#include <iostream>

#include "ConvertTimeHeader.h"

using namespace std;

int convertTime::invalidHr (int hour)

{

try{

 if (hour < 13 && hour > 0)

  {hour = hour + 12;

  return hour;}

 else{

 

  cin.clear();

  cin.ignore();

  cout << "Invalid input! Please input hour again in correct 12 hour format: ";

  cin >> hour;

  invalidHr(hour);

  throw 10;

 }

   

}

catch (int c) { cout << "Invalid hour input!";}

}

int convertTime::invalidMin (int min)

{

try{

 if (min < 60 && min > 0)

  {return min;}

 else{

 

  cin.clear();

  cin.ignore();

  cout << "Invalid input! Please input minutes again in correct 12 hour format: ";

  cin >> min;

  invalidMin(min);

  throw 20;

  return 0;

 }

   

}

catch (int e) { cout << "Invalid minute input!" << endl;}

}

int convertTime::invalidSec(int sec)

{

try{

 if (sec < 60 && sec > 0)

  {return sec;}

 else{

 

  cin.clear();

  cin.ignore();

  cout << "Invalid input! Please input seconds again in correct 12 hour format: ";

  cin >> sec;

  invalidSec(sec);

  throw 30;

  return 0;

 }

   

}

catch (int t) { cout << "Invalid second input!" << endl;}

}

void convertTime::printMilTime()

{

cout << "Your time converted: " << hour << ":" << min << ":" << sec;

}

Explanation:

You might be interested in
A Service Schedule is...
VikaD [51]

Answer:

option c

Explanation:

8 0
3 years ago
Read 2 more answers
In the planning process of the product development life cycle what is it important to inventory
Verizon [17]

Your Answer would be A I believe.

6 0
3 years ago
Which of following are coding languages used in controlling a robot? *
Bess [88]

Answer:

C/C++

Explanation:

C/C++

7 0
3 years ago
The roof of a refrigerated truck compartment consists of a layer of foamed urethane insulation (t2 = 21 mm, ki = 0.026 W/m K) be
lakkis [162]

Answer:

Tso = 28.15°C

Explanation:

given data

t2 = 21 mm

ki = 0.026 W/m K

t1 = 9 mm

kp = 180 W/m K

length of the roof is L = 13 m

net solar radiation into the roof = 107 W/m²

temperature of the inner surface Ts,i = -4°C

air temperature is T[infinity] = 29°C

convective heat transfer coefficient h = 47 W/m² K

solution

As when energy on the outer surface at roof of a refrigerated truck that is balance as

Q = \frac{T \infty - T si }{\frac{1}{hA}+\frac{t1}{AKp}+\frac{t2}{AKi}+\frac{t1}{aKp}}       .....................1

Q = \frac{T \infty - Tso}{\frac{1}{hA}}                         .....................2

now we compare both equation 1 and 2 and put here value

\frac{29-(-4)}{\frac{1}{47}+\frac{2\times0.009}{180}+\frac{0.021}{0.026}} = \frac{29-Tso}{\frac{1}{47}}            

solve it and we get

Tso = 28.153113

so Tso = 28.15°C

3 0
3 years ago
What is the purpose of gears?
Brrunno [24]

Answer:

To help wheels move in a circle

Explanation:

6 0
3 years ago
Other questions:
  • **Please Help, ASAP**
    6·1 answer
  • A belt/pulley system has tight side of 1000N, a slack side of 100N and a wrap angle of 500 degrees. The belt is just on the poin
    5·1 answer
  • A 3-phase induction motor with 4 poles is being driven at 45 Hz and is running in its normal operating range. When connected to
    12·1 answer
  • Two piezometers have been placed along the direction of flow in a confined aquifer that is 30.0 m thick. The piezometers are 280
    6·1 answer
  • A force is a push or pull in? A.a circle B.an arc C.a straight line
    5·1 answer
  • 6.
    8·1 answer
  • Why charles babbage is known as father of computer explain <br>​
    12·1 answer
  • A single-phase load is located 2800 ft from its source. The load draws a current of 86 A and operates on 480 V. The maximum volt
    10·1 answer
  • Lets Try This: study the pictures. Describe what you see and think about it. write your answer on a sheet of paper. home room
    15·1 answer
  • Which pipe for water is best for construction?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!