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
Why is it important for engineers to consider both short and long term implications of their work?
polet [3.4K]
The right answer should be A).
7 0
3 years ago
Just to let you know Christmas is in 10 days&lt;3<br><br> lol
Harrizon [31]

Answer:

yay yay

Explanation:

im so excited i cant wait

7 0
3 years ago
Read 2 more answers
A 1020 Cold-Drawn steel shaft is to transmit 20 hp while rotating at 1750 rpm. Calculate the transmitted torque in lbs. in. Igno
velikii [3]

Answer:

Question 1 A 1020 Cold-Drawn steel shaft is to transmit 20 hp while rotating at 1750 rpm. Calculate the transmitted torque in lbs. in. Ignore the effect of friction. Answer with three decimal points. 60.024 Question 2 Based on the maximum-shear-stress theory, determine the minimum diameter in inches for the shaft in Q1 to provide a safety factor of 3. Assume Sy = 57 Kpsi. Answer with three decimal points. 0.728 Question 3 If the shaft in Q2 was made of ASTM 30 cast iron, what would be the factor of safety? Assume Sut = 31 Kpsi, Suc = 109 Kpsi 0 2.1 O 2.0 O 2.5 0 2.4 2.3 O 2.2

Explanation:

hope it helps

4 0
2 years ago
To ensure that a vehicle crash is inelastic, vehicle safety designers add crumple zones to vehicles. A crumple zone is a part of
spin [16.1K]

Answer:

Explanation:

Answer: With crumple zones at the front and back of most cars, they absorb much of the energy (and force) in a crash by folding in on itself much like an accordion. ... As Newton's second law explains force = Mass x Acceleration this delay reduces the force that drivers and passengers feel in a crash.Sep 30, 2020

5 0
3 years ago
A 225 MPa conducted in which the mean stress was 50 MPa and the stress amplitude was (a) Compute the maximum and (b) Compute the
tamaranim1 [39]

Answer:

Explanation:

Given data in question

mean stress  = 50 MPa

amplitude stress  = 225 MPa

to find out

maximum stress, stress ratio, magnitude of the stress range.

solution

we will find first  maximum stress  and minimum stress

and stress will be sum of (maximum +minimum stress) / 2

so for stress 50 MPa and 225 MPa

\sigma _{m} =  \sigma _{maximum} + \sigma _{minimum}  / 2

50 =  \sigma _{maximum} + \sigma _{minimum}  / 2    ...........1

and

225 =  \sigma _{maximum} + \sigma _{minimum}  / 2      ...........2

from eqution 1 and 2 we get maximum and minimum stress

\sigma _{maximum} = 275 MPa        ............3

and \sigma _{minimum} = -175 MPa     ............4

In 2nd part we stress ratio is will compute by ratio of equation 3 and 4

we get ratio =  \sigma _{minimum} / \sigma _{maximum}

ratio = -175 / 227

ratio = -0.64

now in 3rd part magnitude will calculate by subtracting maximum stress - minimum stress i.e.

magnitude = \sigma _{maximum} - \sigma _{minimum}  

magnitude = 275 - (-175) = 450 MPa

3 0
3 years ago
Other questions:
  • . A line shaft rotating at 200 r.p.m. is to transmit 20 kW. The allowable shear stress for the material of the shaft is 42 MPa.
    7·1 answer
  • How much to build a barber clipper?
    10·1 answer
  • Determine whether w is in the span of the given vectors v1; v2; : : : vn
    8·1 answer
  • A heat engine receives 6 kW from a 250oC source and rejects heat at 30oC. Examine each of three cases with respect to the inequa
    7·1 answer
  • A gas contained within a piston-cylinder undergoes the follow change in states: Process 1: Constant volume from p1 = 1 bar V1 =
    9·1 answer
  • Nearly__________ of all serious occupational injuries and illnesses stem from overexertion of repetitive motion.a. 1/2b. 1/4c. A
    10·1 answer
  • Creating vacancies in ceramics. Consider doping ZrO2 with small concentrations of Nb205. The valence of Nb is 5. Assume that Nb
    10·1 answer
  • Water flows near a flat surface and some measurements of the water velocity, u, parallel to the surface, at different heights y
    8·1 answer
  • WHICH OF THIS PLS FAST!!!
    5·1 answer
  • The raised areas between the grooves in a rifled bore are called:.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!