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
Consider the formation of p-nitrophenol from p-nitrophenyl trimethyl acetate. The process is known as enzymatic hydrolysis and i
solniwko [45]

Solution :

cs=zeros(9001);

ca=zeros(9001);

cp=zeros(9001);

psi=zeros(9001);

t=[0:0.1:900];

cs(1)=0.5;

ce(1)=0.001;

cp(1)=0;

ca(1)=0;

psi(1)=0;

for i=1:1:9000

cs(i+1)=cs(i)-0.1*((0.015*cs(i))/(5.53+cs(i)));

cp(i+1)=cp(i)+0.1*((0.015*cs(i))/(5.53+cs(i))-0.0026*cp(i));

ca(i+1)=ca(i)+0.1*0.0026*cp(i);

psi(i+1)=((cp(i+1)-cp(i)))/((cs(i)-cs(i+1)));

end

plot(t,cs,t,cp,t,ca);

plot(t,psi);

6 0
3 years ago
What is the weight of a glider with a mass of 4.9 grams?
timama [110]

Answer:

0.0481 N

Explanation:

The mass of a body is the quantity of matter stored in that body. It is a property that measures resistance to acceleration when a force is applied. The S.I unit of mass is the kilogram (kg).

The weight of a body is the force exerted on that body by gravity. The S.I unit of weight is the Newton (N). The weight of an object can also be defined as the force acting on the object. The formula for weight is:

Weight (W) = Mass (m) × acceleration due to gravity(g).

Giving that: mass (m) = 4.9 g = 0.0049 g and acceleration due to gravity (g) = 9.81 m/s².

Therefore, Weight (W) = 0.0049 × 9.81 = 0.0481 N

4 0
3 years ago
engineering controls are devices such as self sheathing needles and sharps containers to block or eliminate the sharp risk. true
Paladinen [302]

Answer:

yes

Explanation:

The 1991 standard states, "engineering and work practice controls shall be used to eliminate or minimize employee exposure." The revision defines Engineering Controls as "controls (e.g., sharps disposal containers, self-sheathing needles, safer medical devices, such as sharps with engineered sharps injury protections ...

6 0
3 years ago
Which step of the critical thinking process determines the main idea to be understood in order for the information or data to ma
bekas [8.4K]
The answer is D concept. For example, I grasp the concept of the idea.
4 0
3 years ago
Please help me please
VashaNatasha [74]

Answer: C

Explanation:

5 0
3 years ago
Other questions:
  • Race conditions are possible in many computer systems. Consider an online auction system where the current highest bid for each
    10·1 answer
  • An engineer devises a scheme for extracting some power from waste process steam. The engineer claims that the steam enters the d
    15·1 answer
  • "Hint: A backslash \ in a string acts as an escape character, such as with a newline \n. So, to print an actual backslash, escap
    6·1 answer
  • Snoopy is inflated for the Macy’s Thanksgiving parade with 50,000 L of He at 25 oC and 1.2 atm. What is the percent decrease in
    15·1 answer
  • What is the movement of the piston from top dead center (TDC) to bottom dead center (BDC) called?
    9·1 answer
  • A car is accelerated 5.5 ft/s^2. Calculate the initial velocity v, the car must have if it is to attain a final velocity v of 45
    6·1 answer
  • What are the desired characteristics or values for the following parameters of an ideal amplifier?o Phase change as a function o
    10·1 answer
  • Apply the particle under a net force model to the block in the horizontal direction:1) Fx = F cos θ - fk - T = m2ax = m2aApply
    15·1 answer
  • Select the appropriate SDLC process model to develop the VHROM system.
    15·1 answer
  • Drivers education :Anything that draws your mind off driving is
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!