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
Think for a moment about the potential problems with big data that the speaker mentioned:
Natalka [10]

Answer: 1. sadly yes, some people are treated unfairly for crimes people yet have commited. 2. no 3. yes

Explanation:

i did this last year

5 0
3 years ago
Read 2 more answers
If the average speed of a car is 45 km/jr, how far can it travel in 40 minutes?
Sholpan [36]

Answer:

30km

Explanation:

speed = distance ÷ time

3 0
2 years ago
Describe experimental factors that could be modified, and unalterable properties of materials used.
Sphinxa [80]

Answer:

a. mechanical properties

b. thermal properties

c. chemical properties

d. electical properties

e. magnetic properties

Explanation:

a. The mechanical properties of a material are those properties that involve a reaction to an applied load.The most common properties considered are strength, ductility, hardness, impact resistance, and fracture toughness, elasticity, malleability, youngs' modulus etc.

b. Thermal properties such as boiling point , coefficient of thermal expansion , critical temperature  , flammability  , heat of vaporization , melting point ,thermal conductivity , thermal expansion ,triple point , specific heat capacity

c. Chemical properties such as corrosion resistance , hygroscopy , pH , reactivity , specific internal surface area , surface energy , surface tension

d. electrical properties such as capacitance , dielectric constant , dielectric strength , electrical resistivity and conductivity , electric susceptibility , nernst coefficient (thermoelectric effect) , permittivity  etc.

e. magnetic properties such as diamagnetism,  hysteresis,  magnetostriction , magnetocaloric coefficient , magnetoresistance , permeability , piezomagnetism , pyromagnetic coefficient

3 0
3 years ago
Ethan is an engineer who is trying to create a totally quiet fluid power system. Which part of the fluid power system will he ne
creativ13 [48]

Answer:

C: compressor

Explanation:

As it states in the text, Unfortunately, the pump or compressor in a fluid power system is often noisy and heavy. This aspect of the fluid power system is a critical area of interest for engineers and scientists who seek to improve fluid power.

3 0
3 years ago
Read 2 more answers
Find the velocity and rate of flow of water through a rectangular channel of 6m wide and 3m deep when it's running full. The cha
Elza [17]

Answer:

V = 1.5062 m/s

Explanation:

look to the photos

5 0
3 years ago
Other questions:
  • The boiler pressure is 38bar and the condenser pressure 0.032 bar.The saturated steam is superheated to 420 oC before entering t
    8·1 answer
  • A mixing basin in a sewage filtration plant is stirred by a mechanical agitator with a power input/WF L T=. Other parameters de
    8·1 answer
  • Superheated steam is stored in a large tank at 6 MPa and 800°C, The steam is exhausted isentropically through a converging-diver
    5·1 answer
  • Select the characteristics of an ideal operational amplifier.
    5·1 answer
  • A kernel-level thread wishes to acquire a mutex lock declared as global in the process. True or False: the function call used be
    6·1 answer
  • Shear modulus is analogous to what material property that is determined in tensile testing? (a)- Percent reduction of area (b) Y
    11·1 answer
  • What are the prefixes for 1, 10, 1000, 1,000,000, .1, .01, .001, .000001
    9·1 answer
  • Please please help please with this this is the link for the story PLEASE PLEASE HELP PLEASE PLEASE help please
    7·1 answer
  • What is the difference between the elements of design and the principles of design? Define at
    7·1 answer
  • Describe how you could engineer the situation to produce even more friction and heat
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!