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
If you are exposed to potentially infectious material via a sharps injury, what should you do immediately?
Sergio039 [100]

The correct answer is "immediately flood the area with water and clean the wound."

Further Explanation:

If someone is exposed to a potentially infectious material with a sharps item such a needle, they need to wash the area with clean water immediately. It must be a steady flow of water to get out any potential infectious material.

After flushing the injury with water, you will then wash the area or exposed skin with soap, if at all possible use a disinfectant on the area.

The person who was injured should seek medical assistance for tests to be sure that they have not been affected.

Learn more about infectious material at  brainly.com/question/10928952

#LearnwithBrainly

4 0
3 years ago
A defective crankshaft position sensor is a common cause of a no-start condition.
ohaa [14]

Answer:

Switching on and off

Explanation:

No starters are often caused by a faulty crankshaft actuator. The signals from this transmitter is sent to the ignition module, which turns in and out of the ignition system. If you already have an RPM sign, it's possible that a faulty ignition unit or PCM isn't turning the coils on and off. Along with button on and the motor cranking, testing for volts at the contacts with a voltmeter.

3 0
3 years ago
Select the correct answer. Which material is commonly preferred for detailed projects such as connectors, jewelry, or small part
Naya [18.7K]

Answer:

the mean time I was wondering if you have any questions or need any further information please contact me at the mean time

4 0
3 years ago
Use Lagrange multiplier techniques to find the local extreme values of the given function subject to the stated constraint. If a
Leno4ka [110]

Answer:

Explanation:

Given f(x, y) = 5x + y + 2 and g(x, y) = xy = 1

The step by step calculation and appropriate substitution is clearly shown in the attached file.

5 0
3 years ago
Find the second derivative of: y = sqrt(x + 4)/4; x ≥ -4.
hammer [34]

Answer: \dfrac{-1}{16(x+4)^{\frac{3}{2}}}

Explanation:

Given

y=\dfrac{\sqrt{x+4}}{4}\\\text{differentitate w.r.t x}\\\dfrac{\mathrm{d} y}{\mathrm{d} x}=\dfrac{1}{4}\times \dfrac{1}{2\sqrt{x+4}}=\dfrac{1}{8\sqrt{x+4}}

\dfrac{\mathrm{d} y}{\mathrm{d} x}=\dfrac{(x+4)^{-0.5}}{8}

Again differentiate for the second derivative

\frac{\mathrm{d^2} y}{\mathrm{d} x^2}=\dfrac{1}{8}\times \dfrac{-1}{2(x+4)^{\frac{3}{2}}}=\dfrac{-1}{16(x+4)^{\frac{3}{2}}}

8 0
3 years ago
Read 2 more answers
Other questions:
  • A murder in a downtown office building has been widely publicized. You’re a police detective and receive a phone call from a dig
    9·2 answers
  • Solid spherical particles having a diameter of 0.090 mm and a density of 2002 kg/m3 are settling in a solution of water at 26.7C
    8·1 answer
  • A gear train has two gears. The driver gear has 8 teeth and a diametral pitch of 6 teeth/inch. the follower gear has 24 teeth. W
    13·1 answer
  • Consider a well-insulated horizontal rigid cylinder that is divided into two compartments by a piston that is free to move but d
    14·1 answer
  • Ammonia enters the expansion valve of a refrigeration system a temperature of 24oC and pressure of10 bar and exits at 1 bar. If
    12·1 answer
  • You need to lift a 2012 Toyota Highlander and haven't done so in a while. Which of these are reliable sources for checking the c
    10·1 answer
  • The heavier an atomic nucleus gets, the less energy the star is able to extract from it through nuclear fusion. When it gets to
    7·1 answer
  • A hot plate with a temperature of 60 C, 50 triangular profile needle wings of length (54 mm), diameter 10 mm (k = 204W / mK) wil
    6·1 answer
  • Thermal energy storage systems commonly involve a packed bed of solid spheres, through which a hot gas flows if the system is be
    5·1 answer
  • Process synchronization can be done on
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!